2012-05-02  Dmitry V. Levin  <ldv@altlinux.org>

	Prepare for 4.7 release.
	* configure.ac: Version 4.7.
	* debian/changelog: 4.7-1.
	* strace.spec: 4.7-1.

	Fix build with <linux/loop.h> from 2.6.18 kernel headers.
	* configure.ac: Check for LO_FLAGS_AUTOCLEAR and LO_FLAGS_PARTSCAN
	declarations.
	* loop.c (loop_flags_options): Use LO_FLAGS_AUTOCLEAR and
	LO_FLAGS_PARTSCAN only when appropriate declarations are available.
	(loop_ioctl): Use LOOP_SET_CAPACITY only when it is defined.

2012-05-01  Dmitry V. Levin  <ldv@altlinux.org>

	* vsprintf.c: Check for USE_CUSTOM_PRINTF earlier.

	Remove duplicate names from CREDITS.
	* .mailmap: Merge email addresses.
	* CREDITS.in: Remove a duplicate name.

	tests: raise strace check timeout to 60 seconds.
	* tests/init.sh (check_timeout): New variable.
	* tests/ptrace_setoptions: Use it.
	* tests/strace-f: Likewise.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

	Update STA_* constants.
	* time.c (adjtimex_status): Add STA_NANO, STA_MODE, and STA_CLK.
	* NEWS (Improvements): Mention it.

	NEWS: update for release.
	* NEWS (Improvements): Mention recent recvmsg/recvmmsg decoders
	enhancements.
	(Portability): Add a recommendation for the minimum Linux kernel
	version to use.

	Make printing of utsname.domainname more portable.
	* configure.ac: Check for struct utsname.domainname field.
	* process.c (sys_uname): Print utsname.domainname when the field is
	available.

	Fix recvmmsg decode: do not show more data than actually returned.
	This change complements recent fix for recvmsg decoding.

	* net.c (printmmsghdr): Add msg_len parameter to pass down to do_msghdr.
	When this parameter is zero, pass mmsghdr.msg_len to do_msghdr instead.
	(decode_mmsg): Add msg_len parameter, pass it down to printmmsghdr.
	(sys_sendmmsg): Call decode_mmsg with msg_len == (unsigned long) -1L.
	(sys_recvmmsg): Call decode_mmsg with msg_len == 0.

	Remove recently introduced use of ULONG_MAX.
	* io.c: Remove limits.h inclusion.
	(tprint_iov): Use "(unsigned long) -1L" instead of "ULONG_MAX".
	* net.c: Remove limits.h inclusion.
	(printmmsghdr, sys_sendmsg): Use "(unsigned long) -1L" instead of
	"ULONG_MAX".

2012-04-28  Denys Vlasenko  <vda.linux@googlemail.com>

	Enable printing of uts.domainname in uname syscall.
	* process.c (sys_uname): Enable printing of uts.domainname

	Fix printstr's len parameter width.
	We often pass syscall params and other long-sized values
	as printstr(len). Truncating them to int may be a bad thing.

	* defs.h: Change len parameter's type from int to long in
	string_quote and printstr function declarations.
	* util.c (string_quote): Special-case only len==-1, not all len<0.
	(printstr): Likewise.

	Fix recvmsg decode: do not show more data than actually returned.
	I noticed that "hostname -d" talks over netlink and gets 20 bytes
	of response, but we show entire 1024 bytes of iov.
	This changes fixes that.

	* defs.h: New function tprint_iov_upto.
	* io.c (tprint_iov_upto): Definition of this function.
	(tprint_iov): Call tprint_iov_upto.
	* net.c (do_msghdr): Add data_size parameter, pass it down to tprint_iov_upto.
	(printmsghdr): Add data_size parameter, pass it down to do_msghdr.
	(printmmsghdr): Call do_msghdr with data_size==ULONG_MAX.
	(sys_sendmsg): Call printmsghdr with data_size==ULONG_MAX.
	(sys_recvmsg): Call printmsghdr with data_size==tcp->u_rval.

2012-04-27  Dmitry V. Levin  <ldv@altlinux.org>

	Package strace-log-merge.
	* strace.spec (%files): Add strace-log-merge.

2012-04-27  Mike Frysinger  <vapier@gentoo.org>

	NEWS: clarify & fix typo.

	Cast current_wordsize to an int.
	On 64bit systems with a single personality, we see:
	count.c: In function 'call_summary':
	count.c:223:5: warning: format '%u' expects type 'unsigned int',
		but argument 3 has type 'long unsigned int'

	Since on multi-personality systems this is an array of ints, cast
	the multiplication to an int and update the printf format.

	* count.c (call_summary): Change %u to %d and cast first argument to int.

2012-04-20  Dmitry V. Levin  <ldv@altlinux.org>

	Update NEWS for upcoming 4.7 release.
	* NEWS: Update for 4.7 release.

	Sync strace.spec and debian/ with packages.
	* debian/changelog: Sync with 4.5.20-2.3.
	* debian/control: Likewise.
	* strace.spec: Sync with 4.6-2.

2012-04-18  Mike Frysinger  <vapier@gentoo.org>

	Decode /dev/loop ioctls.
	Needed to debug some losetup failures, and it's easier when you can see
	what the kernel is getting vs what you think you're sending, so add some
	decoders for those ioctls.

	* loop.c: New file.
	* Makefile.am (strace_SOURCES): Add loop.c.
	* defs.h (loop_ioctl): New prototype.
	(string_quote): Likewise.
	* ioctl.c (ioctl_decode): Call loop_ioctl when code is 'L'.
	* util.c (string_quote): Remove static keyword.

2012-04-18  H.J. Lu  <hongjiu.lu@intel.com>

	x32: add ia32 support.
	* Makefile.am (EXTRA_DIST): Add linux/x32/errnoent1.h,
	linux/x32/ioctlent1.h, linux/x32/signalent1.h and
	linux/x32/syscallent1.h.
	* configure.ac: Remove AC_GNU_SOURCE, obsoleted by
	AC_USE_SYSTEM_EXTENSIONS.
	* defs.h (SUPPORTED_PERSONALITIES): Set to 2 for X32.
	(PERSONALITY1_WORDSIZE): Set to 4 for X32.
	* file.c (stat64): New struct for X32.
	(sys_lseek32): New function for X32.
	(stat64): Undef.
	(sys_fstat64): Likewise.
	(sys_stat64): Likewise.
	(realprintstat64): New function for X32.
	(sys_fstat64): Likewise.
	(sys_stat64): Likewise.
	* mem.c (sys_old_mmap): New function for X32.
	* pathtrace.c (pathtrace_match): Also check sys_old_mmap for X32.
	* syscall.c (update_personality): Add X32 support.
	(get_scno): Support currpers == 1 for X32.
	* linux/syscall.h (sys_lseek32): New function prototype for X32.
	* linux/x32/errnoent1.h: New file.
	* linux/x32/ioctlent1.h: Likewise.
	* linux/x32/signalent1.h: Likewise.
	* linux/x32/syscallent1.h: Likewise.

2012-04-17  H.J. Lu  <hongjiu.lu@intel.com>

	Cast clock_t type to unsigned long long.
	* resource.c (sys_times): Cast clock_t type to unsigned long long.
	* signal.c (printsiginfo): Likewise.

2012-04-16  Denys Vlasenko  <vda.linux@googlemail.com>

	Add custom (faster) vfprintf implementation (disabled by default)
	* defs.h: Declare strace_vfprintf either as a alias to vfprintf
	or as a bona fide function. USE_CUSTOM_PRINTF define controls whether
	we use strace_vfprintf. By default, we don't.
	* strace.c (tprintf): Call strace_vfprintf instead of vfprintf.
	* vsprintf.c: New file, implements strace_vfprintf.

	Stop using %h[h]u format specifiers.
	This is needed for simplified printf, and reduces code size a bit.

	* block.c (block_ioctl): Cast the value to unsinged and use %u
	instead of using %hu.
	* desc.c (sys_io_cancel): Likewise.
	* resource.c (sys_sysinfo): Likewise.

	Trivial speed optimization.
	* strace.c (tprints): Use fputs_unlocked instead of fputs.

2012-04-16  H.J. Lu  <hongjiu.lu@intel.com>

	Fix a problem with sys_lseek on x32.
	* file.c (sys_lseek): Use MIPS-n32 variant also for x32

	Add x32 support to strace.
	X32 support is added to Linux kernel 3.4. In a nutshell, x32 is x86-64 with
	32bit pointers.  At system call level, x32 is also identical to x86-64,
	as shown by many changes like "defined(X86_64) || defined(X32)".  The
	main differerence bewteen x32 and x86-64 is off_t in x32 is long long
	instead of long.

	This patch adds x32 support to strace.  Tested on Linux/x32.

	* configure.ac: Support X32.
	* defs.h: Set SUPPORTED_PERSONALITIES to 3 for X86_64,
	Set PERSONALITY2_WORDSIZE to 4 for X86_64.
	Add tcb::ext_arg for X32.
	* file.c (stat): New for X32.
	(sys_lseek): Use 64-bit version for X32.
	(printstat64): Check current_personality != 1 for X86_64.
	* ipc.c (indirect_ipccall): Check current_personality == 1
	for X86_64.
	* mem.c (sys_mmap64): Also use tcp->u_arg for X32.  Print NULL
	for zero address.  Call printllval for offset for X32.
	* pathtrace.c (pathtrace_match): Don't check sys_old_mmap for
	X32.
	* process.c (ARG_FLAGS): Defined for X32.
	(ARG_STACK): Likewise.
	(ARG_PTID): Likewise.
	(change_syscall): Handle X32.
	(struct_user_offsets): Support X32.
	(sys_arch_prctl): Likewise.
	* signal.c: Include <asm/sigcontext.h> for X32.
	(SA_RESTORER): Also define for X32.
	* syscall.c (update_personality): Support X32 for X86_64.
	(is_restart_error): Likewise.
	(syscall_fixup_on_sysenter): Likewise.
	(get_syscall_args): Likewise.
	(get_syscall_result): Likewise.
	(get_error): Likewise.
	(__X32_SYSCALL_BIT): Define if not defined.
	(__X32_SYSCALL_MASK): Likewise.
	(get_scno): Check DS register value for X32.  Use
	__X32_SYSCALL_MASK on X32 system calls.
	* util.c (printllval): Use ext_arg for X32.
	(printcall): Support X32.
	(change_syscall): Likewise.
	(arg0_offset): Likewise.
	(arg1_offset): Likewise.
	* Makefile.am (EXTRA_DIST): Add linux/x32/errnoent.h,
	linux/x32/ioctlent.h.in, linux/x32/signalent.h,
	linux/x32/syscallent.h, linux/x86_64/errnoent2.h,
	linux/x86_64/ioctlent2.h, linux/x86_64/signalent2.h and
	linux/x86_64/syscallent2.h.
	* linux/x32/errnoent.h: New.
	* linux/x32/ioctlent.h.in: Likewise.
	* linux/x32/signalent.h: Likewise.
	* linux/x32/syscallent.h: Likewise.
	* linux/x86_64/errnoent2.h: Likewise.
	* linux/x86_64/ioctlent2.h: Likewise.
	* linux/x86_64/signalent2.h: Likewise.
	* linux/x86_64/syscallent2.h: Likewise.

	Restore tcb::u_lrval; fix lseek on MIPS-n32.
	Linux kernel v3.4 adds x32 support.  Both x32 and n32 use 64bit offset
	for lseek parameter and return value.  We need u_lrval to handle it
	properly.  Also we shouldn't check HAVE_LONG_LONG_OFF_T for n32 lseek.
	This patch fixes it properly and prepares lseek for x32.

	* defs.h (tcb): Restore tcb::u_lrval field, RVAL_Lfoo constants.
	Set RVAL_MASK to 7.
	* file.c (sys_lseek): Print 64bit offset and return RVAL_LUDECIMAL
	for n32.
	* syscall.c (get_error): Set u_lrval for MIPS-n32.
	(trace_syscall_exiting): Handle RVAL_Lfoo return value types.

2012-04-06  Mike Frysinger  <vapier@gentoo.org>

	Decode mtd ioctls.
	I got tired of figuring out mtd structures (which show up a lot
	in the embedded space), so add decoders for those ioctls.

	* defs.h (mtd_ioctl): New prototype.
	(print_loff_t): Likewise.
	* io.c (print_loff_t): Delete static keyword
	* ioctl.c (ioctl_decode): Call mtd_ioctl when code is 'M'.
	* Makefile.am (strace_SOURCES): Add mtd.c.
	(EXTRA_DIST): Add linux/mtd-abi.h.
	* mtd.c: New file.
	* linux/mtd-abi.h: New file.

2012-04-05  Mike Frysinger  <vapier@gentoo.org>

	Fix indefinite hang on no-mmu systems.
	The ptrace setoptions code will fork a child which goes to sleep and
	expects the parent to continue on to do tests.  Unfortunately, this
	does not work on no-mmu systems as fork() is actually vfork() and any
	vforked children will hang the parent until it exits or execs.

	We might be able to make this test work on no-mmu systems with a bit
	of work, but easier to just disable this for the release so it works
	now.

	* strace.c (test_ptrace_setoptions_for_all): Return if strace_vforked.

2012-03-29  Denys Vlasenko  <vda.linux@googlemail.com>

	Makefile.am: whitespace fix.

2012-03-27  Anton Blanchard  <anton@samba.org>

	powerpc: Add syscall entries for direct socket system calls.
	* linux/powerpc/syscallent.h: Add direct socket system calls.

2012-03-26  Dmitry V. Levin  <ldv@altlinux.org>

	qual_syscall: fix potential NULL dereference.
	Fix regression introduced by commit
	c1371ebc400fe9578908beca87f2bf407daf1506

	* syscall.c (qual_syscall): Handle null sys_name.

	Reported-by: Fr. Br. George <george@altlinux.org>

	strace-log-merge: fix file suffix calculation.
	* strace-log-merge: Quote file prefix to fix file suffix calculation.

	Reported-by: Denys Vlasenko <vda.linux@googlemail.com>
	Suggested-by: Andreas Schwab <schwab@linux-m68k.org>

2012-03-26  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove unreachable code.
	* strace.c (process_opt_p_list): Remove unreachable code.

	manpage: remove false info about -p being limited to 32 processes.

	Tweak help text and manpage (added -In to manpage)

2012-03-25  Dmitry V. Levin  <ldv@altlinux.org>

	printstr: check for potential integer overflow.
	* util.c (printstr): Check for potential integer overflow during outstr
	buffer size calculation.

	Robustify parsing of numbers from strings.
	* defs.h (string_to_uint): New prototype.
	* util.c (string_to_uint): New function.
	* strace.c (error_opt_arg): New function.
	(process_opt_p_list): Use string_to_uint instead of atoi.
	Terminate in case of invalid process id.
	(init): Use string_to_uint instead of atoi.
	Use error_opt_arg in case of invalid option argument.
	* syscall.c (qual_syscall, qual_signal, qual_desc): Use string_to_uint
	instead of atoi.

	strace-log-merge: enhance usage error diagnostics.
	* strace-log-merge: Add --help option.  Check number of arguments.
	Issue an error message when no strace output was merged.

	configure.ac: sort lists and use m4_normalize to ease maintenance.
	* configure.ac (AC_CHECK_FUNCS, AC_CHECK_HEADERS, AC_CHECK_MEMBERS,
	AC_CHECK_DECLS): Sort lists, use m4_normalize.

2012-03-23  Denys Vlasenko  <vda.linux@googlemail.com>

	Simple optimizations.
	Why open-coding isdigit is a good idea?

	Before: call   __ctype_b_loc
	        movzbl (%ebx),%edx
	        mov    (%eax),%eax
	        testb  $0x8,0x1(%eax,%edx,2)
	        je     lbl

	After:  movzbl (%eax),%edx
	        sub    $0x30,%edx
	        cmp    $0x9,%dl
	        ja     lbl

	   text	   data	    bss	    dec	    hex	filename
	 236869	    704	  18944	 256517	  3ea05	strace.before
	 236719	    700	  18944	 256363	  3e96b	strace

	* defs.h: Alias sigemptyset to __sigemptyset on glibc.
	* syscall.c (qual_syscall): Open-code isdigit.
	(qual_desc): Likewise.
	(qual_signal): Open-code isdigit. Remove string copying
	which was done for no apparent reason.

	Reorder declarations in defs.h. No code changes.
	* defs.h: Reorder declarations (such as: keep all printing functions together).

2012-03-22  Denys Vlasenko  <vda.linux@googlemail.com>

	Simplify current tcp switching and current column handling.
	Instead of using "static FILE *outf and static unsigned int curcol"
	to cache current outfile and its position, we can simply
	remember current tcb and use its ->outf and ->curcol.
	This allows to drop numerous "tcp->curcol = curcol" ops in trace().

	Turns out we can't drop "static FILE *outf", but now its role is
	a bit clearer: it newer changes after init, stays == stderr or
	opened to shared log (which may be the same thing if neither -o
	nor -ff was specified). Let's rename it then.

	   text	   data	    bss	    dec	    hex	filename
	 236953	    704	  18944	 256601	  3ea59	strace.before.prev.commit
	 236905	    704	  18944	 256553	  3ea29	strace.before
	 236869	    704	  18944	 256517	  3ea05	strace

	* strace.c: Replace curcol static variable by struct tcb *current_tcp.
	Rename static FILE *outf to shared_log (since it no longer caches tcp->outf).
	(ptrace_restart): Use current_tcp->curcol instead of curcol.
	(tprintf): Check current_tcp != NULL instead of outf != NULL.
	Use current_tcp->outf instead of outf, current_tcp->curcol instead of curcol.
	(tprints): Likewise.
	(line_ended): Likewise.
	(printleader): Switch current tcb by "current_tcp = tcp" istead of
	assignments to outf and curcol.
	(droptcb): Set current_tcp to NULL if we dropped it.
	(startup_child): Rename outf to shared_log.
	(init): Likewise.
	(cleanup): Likewise.
	(trace): Simplify current tcp switching and current column handling.

	Make threaded execve handling code more reabable and somewhat simpler.
	* strace.c (droptcb): Remove outfname check in "outfname && followfork >= 2" -
	with recent changes, followfork >= 2 check guarantees that outfile
	was specified, and _is already opened_.
	(trace): Move tcb existence check before threaded execve handling.
	This allows to remove tcp != NULL checks in threaded execve handling.
	Rewrite threaded execve handling code to be less indented,
	keeping the same logic.

2012-03-21  Denys Vlasenko  <vda.linux@googlemail.com>

	simple cleanups in defs.h. No logic changes.
	* defs.h: Move offsetof macro definition into "libc stuff" section.
	Renumber TCB_foo constants (smaller constants -> sometimes smaller code).
	Remove uoff macro.
	* process.c: Move uoff macro here (sole user).

	Show "+++ exited..." with -C.
	* strace.c (trace): Show "+++ exited..." with -C too.
	Save tcp->curcol after PTRACE_LISTEN failure too, just in case.

	Slight tweak to qemu_multiarch_testing scripts.

	Replace reprinting decision logic.
	After this change, we no longer need to decide when we need
	to set TCB_REPRINT, and when we don't: it's never needed :)

	Well, almost. That pesky pid-changing execve needs special treatment.
	If not it, it'd be possible to nuke TCB_REPRINT...

	While at it, fix a case of mishandled -C.

	* strace.c (printleader): Do not set TCB_REPRINT.
	(trace): Set TCB_REPRINT only for execve with changing pid.
	Fix mishandling of -C.
	* syscall.c (trace_syscall_entering): Do not clear TCB_REPRINT.
	(trace_syscall_exiting): Replace reprinting decision logic.
	Remove call to printargs(): it is known to just return 0 here.

	Report some ptrace failures; nuke tcp->ptrace_errno.
	Report some (not all) ptrace errors, namely,
	errors on ptrace restart operations.

	Before: 10533 sendto(-1, 0x804895e, 17, 0, NULL, 0 <unfinished ...>
	After:  10533 sendto(-1, 0x804895e, 17, 0, NULL, 0 <ptrace(SYSCALL):No such process>

	This tells user that strace failed to let sendto syscall
	to be entered - process was dead at that point of time.
	It is (marginally) better than to always say "<unfinished ...>"

	While at it, patch removes tcp->ptrace_errno.
	I added it many months ago, and it looks that after all
	it is not needed for ptrace error detection: I failed to execute
	a single existing code path which is accessible
	through that variable only.

	* defs.h: Remove struct tcp::ptrace_errno field.
	* strace.c (ptrace_restart): Emit message to log on error.
	(printleader): Remove "if (printing_tcp->ptrace_errno)..." code.
	(trace): Remove !tcp->ptrace_errno check, it's always true.

2012-03-20  Denys Vlasenko  <vda.linux@googlemail.com>

	Eliminate redundant checks of res variable.
	* syscall.c (trace_syscall_entering): Eliminate redundant checks of res variable.
	(trace_syscall_exiting): Likewise.

	Rename POWERPC-specific static variable result to ppc_result.
	* syscall.c: Rename POWERPC-specific static variable result to ppc_result.

	Remove redundant checks in syscall entry/exit, rename badly named function
	* syscall.c (syscall_enter): Rename to get_syscall_args.
	Document its return values.
	(trace_syscall_entering): Don't check get_syscall_args() return
	value for 0, it never returns that.
	(syscall_fixup_on_sysexit): Make it return void.
	(trace_syscall_exiting): Fix up syscall_fixup_on_sysexit()
	call site accordingly.

	Trivial tweaks. No logic changes.
	* process.c (sys_ptrace): Remove unneeded line wrapping.
	* syscall.c (trace_syscall_entering): Use tprints() instead of tprintf().

	Make ptrace_restart() static. No code changes.
	* defs.h: Remove ptrace_restart() declaration.
	* strace.c (ptrace_restart): Move its definition here.
	* util.c (ptrace_restart): Remove its definition.

2012-03-20  Dmitry V. Levin  <ldv@altlinux.org>

	Do not include limits.h unnecessarily.
	* ioctl.c: Remove limits.h inclusion left after the reverted change.

2012-03-20  Denys Vlasenko  <vda.linux@googlemail.com>

	Partially revert last change.
	Thank you Dmitry for spotting it.

	* ioctl.c (compare): Partially revert last change - the new
	comparison logic was buggy.

	Simplify search in ioctl table.
	   text	   data	    bss	    dec	    hex	filename
	 236973	    704	  18944	 256621	  3ea6d	strace.before
	 236929	    704	  18944	 256577	  3ea41	strace

	* ioctl.c (compare): Simplify generation of compare result.
	(ioctl_lookup): Pass key directly, not as part of dummy struct.
	(ioctl_next_match): More readable code. No logic changes.

2012-03-19  Denys Vlasenko  <vda.linux@googlemail.com>

	Update qemu build script: now tries to upload result back to host.

	Shrink space needed by undefined syscalls in syscall tables.
	Undefined syscall looked like this before this change:
	{ 5,    0,      printargs,              "SYS_53"                },
	That is, "SYS_53" string had to be allocated and stored in strace binary.
	Since now SCNO_IN_RANGE() macro requires sysent[scno].sys_func != NULL
	for valid syscalls, we can replace printargs with NULL in such lines
	and make them "invalid", thus not requiring syscall name string.

	Savings on i386:
	   text	   data	    bss	    dec	    hex	filename
	 237389	    704	  18944	 257037	  3ec0d	strace.before
	 236973	    704	  18944	 256621	  3ea6d	strace
	Savings on mips:
	 336551  153692   38320  528563   810b3 strace.before
	 275543  153688   38320  467551   7225f strace

	Tested to still decode undefined syscalls correctly (syscall no. 222 on i386).

	* linux/*/syscallent.h: Replace 'printargs, "SYS_nnn"' with
	'NULL, NULL'.

	Optimize code if we have only one personality.
	On i386:
	   text	   data	    bss	    dec	    hex	filename
	 238025	    672	  18980	 257677	  3ee8d	strace.before
	 237389	    704	  18944	 257037	  3ec0d	strace

	* defs.h: Define PERSONALITY0_WORDSIZE as sizeof(long) if not defined.
	Introduce new define, current_wordsize as
	(personality_wordsize[current_personality]).
	Make set_personality() no-op, current_personality constant zero,
	current_wordsize as PERSONALITY0_WORDSIZE if we have only one personality.
	* count.c (call_summary): Use current_wordsize instead of
	personality_wordsize[current_personality].
	* desc.c (printflock): Likewise.
	* file.c (sys_utime): Likewise.
	* io.c (tprint_iov): Likewise.
	* process.c (printargv): Likewise.
	* resource.c (decode_rlimit): Likewise.
	* signal.c (sys_kill): Likewise.
	(sys_rt_sigaction): Likewise.
	* time.c (sprinttv): Likewise.
	(sprint_timespec): Likewise.
	(printitv_bitness): Likewise.
	(tprint_timex): Likewise.
	(printsigevent): Likewise.
	* util.c (dumpiov): Likewise.
	(umoven): Likewise.
	(umovestr): Likewise.
	* syscall.c: Initialize sysent to sysent0 etc.
	Make current_personality, personality_wordsize[], set_personality()
	conditional on SUPPORTED_PERSONALITIES > 1.

2012-03-18  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix mips64 build failure: sys_pwrite64 doesn't exist.
	sys_pwrite seems to do the same thing as sys_pwrite64
	which we deleted when we removed non-Linux code.

	* linux/mips/syscallent.h: s/sys_pwrite64/sys_pwrite/

	qemu_multiarch_testing/: a directory with scripts for build testing.

	Make internal_fork and internal_exec static.
	   text	   data	    bss	    dec	    hex	filename
	 237917	    672	  18980	 257569	  3ee21	strace
	 237845	    672	  18980	 257497	  3edd9	strace_new

	* defs.h: Remove declarations of internal_fork and internal_exec.
	* process.c: Remove definitions of internal_fork and internal_exec.
	* syscall.c: Move them here.
	(internal_syscall): Return void instead of int. We were always
	returning zero, and callers weren't checking it anyway.

	Remove code which is not used on Linux.
	Compile tested in qemu on armv4l,armv4tl,armv5l,armv6l,i686,
	mipsel,mips,x86_64

	* syscall.c: Remove code which handles RVAL_Lfoo constants.
	* defs.h: Remove struct tcb::u_lrval member - it is never set.
	Remove RVAL_Lfoo constants which signify return of "long" result -
	they are never used.

	Remove unused version of sys_lseek.
	It is buggy: it returns RVAL_LUDECIMAL, which means the return value
	is in tcp->u_lrval. But tcp->u_lrval is never set
	(on Linux - it used to be set on other OSes).

	* file.c (sys_lseek): Remove a version of this function which is
	supposed to be used if off_t is long long. It appears to be buggy
	and unused.

2012-03-17  Denys Vlasenko  <vda.linux@googlemail.com>

	Revert "Remove underscores from a few syscall names which have them"
	This reverts commit 31972d52b1059d8faca1c5f417c2db1a90b868ae.

	Simplify sys_lseek64 conditional compilation.
	It looks like sys_lseek64() is never used.
	For one, it is buggy (always shows 0 return value), and no one complains.

	From code inspection: sys_lseek64 name is not used anywhere.
	It is defined to sys_lseek if HAVE_LONG_LONG_OFF_T is true.
	Thus, if !HAVE_LONG_LONG_OFF_T, it is never used.
	Therefore "if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T"
	conditional it sits in can be simplified to
	"if HAVE_LONG_LONG_OFF_T".
	Therefore, we can move it a bit up and merge with
	"if !HAVE_LONG_LONG_OFF_T, use this sys_lseek()" code block,
	by addind an "else" clause to it.
	To simplify it more, drop define and just rename sys_lseek64 ->
	sys_lseek.

	Since the function is buggy, I think it is unused and we can
	just drop it. (I checked: at least I386 never uses it).

	* file.c (sys_lseek64): Rename to sys_lseek; don't compile it
	if _LFS64_LARGEFILE but !HAVE_LONG_LONG_OFF_T since in this case
	it is never used.

	Remove underscores from a few syscall names which have them.
	Affected names are "_newselect", "_llseek", "_sysctl".
	I see no apparent reason why they have leading underscores.
	Moreover, some arches have underscored names and some have
	non-underscored ones. This is not consistent.

	I verified that every architectire I touched did not have
	a similarly named syscall without underscore, thus this change
	does not introduce new ambiquities.

	I left "_exit" untouched for now, but the same points stand for it too:
	some architectures use "exit" and no one complains. So why many
	arches are using "_exit"?

	* linux/*/syscallent.h: Remove underscores from displayed
	syscall names for _newselect, _llseek, _sysctl.

	Remove unused struct tcb::baddr field.
	* defs.h: Remove unused struct tcb::baddr field.

	Remove unused PTRACE_WRITE{TEXT,DATA} constants (they are from SunOS)
	* util.c: Remove unused PTRACE_WRITE{TEXT,DATA} constants.

	Reindent case labels. No code changes.
	* net.c (printsockopt): Reindent case labels.
	* signal.c (sys_signal): Likewise.

	Remove unused constants. No code changes.
	* syscall.c: Remove unused ENOIOCTLCMD constant. Fix indentation.
	* util.c: Remove unused CLONE_STOPPED constant.

	Move change_syscall() to its only user and make it static.
	* defs.h: Remove declaration of change_syscall().
	* process.c (change_syscall): Remove definition of this function.
	* util.c (change_syscall): Add definition of change_syscall().

	MAP_ANON is the same as MAP_ANONYMOUS, no need to have the former.
	* mem.c: Do not allocate string for MAP_ANON if it is the same as
	MAP_ANONYMOUS.

	Indentation and whitespace fixes. No code changes.

	test/threaded_execve: make it also test a case when leader is not in syscall

2012-03-16  Dmitry V. Levin  <ldv@altlinux.org>

	Implement prlimit64 decoding, rewrite [gs]etrlimit decoding.
	* configure.ac: Remove AC_RLIM_T_IS_LONG_LONG call.
	Define SIZEOF_RLIM_T.
	* m4/long_long.m4 (AC_RLIM_T_IS_LONG_LONG): Remove.
	* linux/dummy.h (sys_prlimit64): Remove.
	* linux/syscall.h (sys_prlimit64): New prototype.
	* resource.c (resources): Reindent, add RLIMIT_RTTIME.
	(sprintrlim, print_rlimit32, sys_getrlimit, sys_setrlimit): Remove.
	[HAVE_LONG_LONG_RLIM_T]: Remove dead code.
	[_LFS64_LARGEFILE || HAVE_LONG_LONG_RLIM_T]: Likewise.
	(sprint_rlim64, print_rlimit64, decode_rlimit64, sprint_rlim32,
	print_rlimit32, decode_rlimit, sys_getrlimit, sys_setrlimit,
	sys_prlimit64): New functions.

2012-03-16  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove another "interrupt to quit" message.
	* strace.c (startup_attach): Remove another "interrupt to quit" message.

	Fix "strace -oFILE -ff -p<nonexistant_pid>" behavior.
	* strace.c (newoutf): Set tcp->outf in non-ff mode too.
	(alloctcb): This define is removed.
	(alloc_tcb): Renamed to alloctcb. Does not set tcp->outf anymore.
	Lost 'command_options_parsed' flag parameter.
	(startup_attach): Do not say "interrupt to quit" in attach message -
	^C does not work in all cases, we mislead users.
	Call newoutf(tcp) after successful attach.
	(startup_child): Call newoutf(tcp) after successful attach.
	(trace): Call newoutf(tcp) when we picked up already attached child.

	Make alloc_tcb and droptcb static. No code changes.
	The change is trivial. Diff is large because it is confused
	by function definitions being moved around.

	* defs.h: Remove declarations of alloc_tcb and droptcb.
	* strace.c: Make alloc_tcb and droptcb static.
	Shuffle functions around to make compiler happy.

	Tidy up includes and copyright notices, fix indentation.
	The files not mentioned in changelog below had only
	copyright notices fixes and indentation fixes.

	* defs.h: Include <stdint.h> and <inttypes.h>.
	* file.c: Do not include <inttypes.h>.
	Move struct kernel_dirent declaration below top include block.
	* block.c: Do not include <stdint.h> and <inttypes.h>.
	* quota.c: Likewise.
	* desc.c: Likewise.
	* signal.c: Likewise.

2012-03-16  Dmitry V. Levin  <ldv@altlinux.org>

	scsi.c: add copyright header.
	* scsi.c: This file was added back in 2007 without a copyright header.
	Add it now.

2012-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance capget and capset syscalls decoding.
	* system.c (cap_version): New xlat structure.
	(print_cap_header, print_cap_data): New functions.
	(sys_capget, sys_capset): Use them.

	Remove unused code.
	* syscall.c (subcall_style, decode_subcall): Remove.
	[SYS_socket_subcall] (decode_socket_subcall): New function, based on
	decode_subcall in deref_style.
	[SYS_ipc_subcall] (decode_ipc_subcall): New function, based on
	decode_subcall in shift_style.
	(trace_syscall_entering): Use decode_socket_subcall and
	decode_ipc_subcall instead of decode_subcall.

	Fix IPC decoding on alpha and arm.
	* ipc.c (indirect_ipccall): Return 0 on ALPHA and ARM EABI.
	(sys_shmat): Use indirect_ipccall for proper return value decoding.

	arm: fix compilation warnings.
	* configure.ac: Define SIZEOF_LONG.
	* signal.c (sys_rt_sigaction) [SUPPORTED_PERSONALITIES > 1]: Help
	compiler to optimize out unreachable code that is not expected to work
	on platforms where sizeof(long) <= 4.

	tests: robustify again buggy shells.
	* tests/init.sh (check_strace): Use "${parameter:-word}" shell syntax
	instead of "${parameter-word}".

	Reported-by: Mike Frysinger <vapier@gentoo.org>

2012-03-15  Mike Frysinger  <vapier@gentoo.org>

	improve ifdef check with decode_subcall.
	Use the same ifdef logic around the call sites of decode_subcall()
	to protect the definition of the func itself.  This fixes warnings
	for targets like hppa which don't use this func.

	* syscall.c (decode_subcall): Wrap in SYS_socket_subcall and
	SYS_ipc_subcall define checks.

	alpha: fix decode of osf_sigprocmask.
	The alpha sigprocmask syscall is special in that it comes from OSF rather
	than the style that everyone else uses.

	Tested with this simple code:
	$ cat test.c
	#include <signal.h>
	main() {
		sigset_t set, oldset;
		sigemptyset(&set);
		sigaddset(&set, SIGINT);
		sigaddset(&set, SIGHUP);
		sigprocmask(SIG_SETMASK, &set, &oldset);
		sigprocmask(SIG_UNBLOCK, &oldset, &set);
		sleep(3);
	}
	$ gcc test.c && ./strace ./a.out
	...
	osf_sigprocmask(SIG_SETMASK, [HUP INT]) = 0 (old mask [])
	osf_sigprocmask(SIG_UNBLOCK, [])        = 0x3 (old mask [HUP INT])
	osf_sigprocmask(SIG_BLOCK, [CHLD])      = 0x3 (old mask [HUP INT])
	...

	* linux/alpha/syscallent.h: Call sys_sigprocmask for osf_sigprocmask,
	and change number of arguments to two.
	* signal.c (sys_sigprocmask): Fix decoding of alpha osf sigprocmask.

2012-03-15  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix array size calculation in previous commit.
	* pathtrace.c (getfdpath): Fix array size calculation.

	pathtrace_select() is never called with NULL, remove dead code.
	pathtrace_select() is only called for -P FILE options,
	and FILE is never a NULL pointer.

	   text	   data	    bss	    dec	    hex	filename
	 239453	    672	  19012	 259137	  3f441	strace.before
	 239329	    672	  19012	 259013	  3f3c5	strace

	* pathtrace.c (pathtrace_select): Remove "if (path == NULL)...".
	(pathtrace_select): Remove code which only executes if path == NULL.
	The code was also buggy, it can free non-malloced pointer.
	(getfdpath): Simplify snprintf to sprintf.
	(pathmatch): Use strcmp() == 0 idiom for string equality test.
	(pathtrace_match): Likewise.

	manpage: remove bugs which are fixed.
	"A traced process ignores SIGSTOP" - fixed, expected to be in linux-3.4.x.
	"A traced process which tries to block SIGTRAP will be sent a SIGSTOP
	in an attempt to force continuation of tracing." - not needed
	and no longer done.
	"On Linux, exciting as it would be, tracing the init process is forbidden"
	- not true anymore.
	"When a traced process receives a SIGTRAP signal not
	associated with tracing, strace will not report that signal correctly."
	- not true anymore.

	Simplify SIGCHLD handler setting.
	* strace.c (init): Set SIGCHLD to SIG_DFL earlier.
	(startup_child): Do not bother restoring SIGCHLD handler.

	When reporting signals, use short signal names (SIGfoo) instead of strerror
	* defs.h: Remove strsignal declaration.
	* signal.c: Better check for SI_FROMUSER define.
	* strace.c (strerror): Remove this function.
	(trace): Use short signal names (SIGfoo) instead of strerror.

	Remove TODO file: it's eleven years old and completely outdated.

	Clean up defs.h order. No code changes.
	* defs.h: Group together related declarations. No code changes.

	Fix lame kernel version checking code.
	The code "os_release[0] >= '3'" is not good for any
	finer-grained checks such as "kernel >= 3.2.1".
	Let's proactively fix it.

	* strace.c: Change os_release from string to integer.
	(get_os_release): Parse uname.release to KERNEL_VERSION
	representation.
	(init): Convert kernel version check to KERNEL_VERSION.

	Experimental support for "detach on execve" feature.
	* strace.c: Define new detach_on_execve, skip_startup_execve bool variables.
	(init): Set detach_on_execve on -b, set skip_startup_execve if
	"strace PROG" form is used.
	(trace): Detach from process if -b and we see PTRACE_EVENT_EXEC event.

	Simple fixes.
	* strace.c (usage): Document -d; document that -F is deprecated.
	(droptcb): Print "<detached ...>" correctly for non-ff mode too.
	(detach): Suppress a warning.

	Remove an outdated comment.
	* defs.h: Remove an outdated comment.

	Remove extra include directives. No code changes.
	* defs.h: Include <signal.h> unconditionally.
	Other files were doing it unconditionally, so no harm done.
	* bjm.c: Remove system includes which are already included by defs.h.
	* pathtrace.c: Likewise.
	* process.c: Likewise.
	* signal.c: Likewise.
	* strace.c: Likewise.
	* stream.c: Likewise.
	* syscall.c: Likewise.
	* system.c: Likewise.
	* util.c: Likewise.

	Tidy up order of includes; make bool variables explicit.
	Bool variables are more compact in data and (on x86) on code too:

	   text	   data	    bss	    dec	    hex	filename
	 237950	    676	  19044	 257670	  3ee86	strace.before
	 237838	    676	  19012	 257526	  3edf6	strace

	* defs.h: Group library includes at the top of the file.
	Rename dtime to Tflag, debug to debug_flag.
	Change debug_flag,Tflag,qflag,not_failing_only,show_fd_path,tracing_paths
	variable declarations from int to bool.
	* strace.c: Change corresponding definitions. Do the same for static
	variables iflag,rflag,print_pid_pfx.
	Rename dtime to Tflag, debug to debug_flag.
	* syscall.c: Rename dtime to Tflag, debug to debug_flag.

2012-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	Fix compiler warnings about breaking strict-aliasing rules.
	* system.c (sys_capget, sys_capset): Use proxy unions to cast long*
	pointers to cap_user_header_t and cap_user_data_t pointers without
	breaking strict-aliasing rules.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

2012-03-15  Mike Frysinger  <vapier@gentoo.org>

	ppc64: drop unused pid variable.
	* syscall.c (get_scno) [POWERPC64]: Delete unused pid variable.

2012-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	ia64: fix compilation warnings.
	* linux/ia64/syscallent.h: Remove improper defines and undefs.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

	Ensure that SWAP_FLAG_* constants are defined.
	* file.c: Define those of SWAP_FLAG_* constants which are not yet
	provided by <sys/swap.h>.

	Reported-by: Mike Frysinger <vapier@gentoo.org>

2012-03-14  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance *listxattr syscalls decoding.
	* file.c (print_xattr_list): New function.
	(sys_listxattr, sys_flistxattr): Use it.

2012-03-13  Dmitry V. Levin  <ldv@altlinux.org>

	Fix *at syscalls flags decoding.
	Several *at decoders were defining own incomplete *atflags xlat
	structures.  That was error prone, and fchownat decoder actually
	failed to recognize AT_EMPTY_PATH.  Merging these incomplete
	structures into the single at_flags xlat structure will fix
	flags handling in all these decoders altogether.

	* file.c: Define all AT_* constants used by *at decoders.
	(at_flags): New xlat structure, with records for all AT_* constants.
	(fstatatflags, linkat_flags, unlinkatflags): Remove.
	(sys_newfstatat, sys_linkat, sys_unlinkat, sys_fchownat,
	sys_utimensat):  Use at_flags.

	Fix linkat flags decoding.
	* file.c (linkat_flags): New xlat structure.
	(sys_linkat): Decode flags using linkat_flags.

	Implement sys_rt_tgsigqueueinfo syscall decoder.
	* linux/dummy.h (sys_rt_tgsigqueueinfo): Remove.
	* linux/syscall.h (sys_rt_tgsigqueueinfo): New prototype.
	* signal.c (print_sigqueueinfo): New function, based on
	sys_rt_sigqueueinfo.
	(sys_rt_sigqueueinfo): Use print_sigqueueinfo.
	(sys_rt_tgsigqueueinfo): New function.

	Implement syslog syscall decoder.
	* linux/dummy.h (sys_syslog): Remove.
	* linux/syscall.h (sys_syslog): New prototype.
	* system.c (syslog_action_type): New xlat structure.
	(sys_syslog): New function.

2012-03-13  Denys Vlasenko  <vda.linux@googlemail.com>

	Less ugly debug display of ptrace events.
	* strace.c (trace): Less ugly debug display of ptrace events.

	Make manpage mention that -p "`pidof PROG`" works.

	Fix logging for "strace -o FILE -ff test/threaded_execve" test case.
	Our logic which was deciding whether to print "<unfinished ...>"
	thingy wasn't working properly for -ff case.

	* defs.h: Group log generation-related declarations together.
	Add a large comment which explains how it works.
	Add declaration of line_ended() function.
	* strace.c (line_ended): New function which sets up internal data
	to indicate that previous line was finished.
	(printleader): Change logic to fix log generation in -ff mode.
	(newoutf): Make check for -ff mode consistent with other places.
	(droptcb): Print "<detached ...>" if last line for this tcp wasn't finished.
	(cleanup): Remove code to print "<unfinished ...>", printleader()
	or detach() will do it instead.
	(trace): Remove code to print "<unfinished ...>".
	Add code which finishes threaded execve's incomplete line
	with " <pid changed to PID ...>" message. Replace printing_tcp = NULL
	followed by fflush() by line_ended() call.
	* process.c (sys_exit): Call line_ended() to indicate that we finished priting.
	* syscall.c (trace_syscall_exiting): Set printing_tcp to current tcp.
	Call line_ended() to indicate that we finished priting.
	Remove call to fflush(), it is done by line_ended() now.

2012-03-13  Dmitry V. Levin  <ldv@altlinux.org>

	net.c: recognize MSG_WAITFORONE.
	* net.c (msg_flags): Add MSG_WAITFORONE.

2012-03-12  Denys Vlasenko  <vda.linux@googlemail.com>

	Treat -ff without -o FILE as single -f.
	* strace.c (init): Treat -ff without -o FILE as single -f.

	Style fix. No code changes.
	* strace.c (process_opt_p_list): Style fix.

	Reduce stack usage by ~0.5k.
	main() uses ~0.5k of stack for local variables and such. When we enter
	main tracing loop, most of these variables are no longer used.
	But they still take up stack for the entire life of strace.
	We can avoid this wastage if we move init code into a separate function.
	(Need to be careful and not allow automatic inlining).

	* strace.c (init): New function. Most of pre-existing code of
	main is now living here.
	(main): Call init() to do initialization.

	Preparatory cosmetic changes for the next commit.
	* strace.c (tprintf): Move function up in the source file. No code changes.
	(tprints): Likewise.
	(printleader): Likewise.
	(tabto): Likewise.

2012-03-11  Dmitry V. Levin  <ldv@altlinux.org>

	Implement sendmmsg syscall decoder.
	* linux/dummy.h (sys_sendmmsg): Remove.
	* linux/syscall.h (sys_sendmmsg): New prototype.
	* net.c (printmmsghdr): Add index argument specifying the element in
	mmsghdr array to print.
	(decode_mmsg): New function, prints the whole mmsghdr array, its length
	and message flags.
	(sys_sendmmsg): New function.
	(sys_recvmmsg): Use decode_mmsg to fix mmsghdr array decoding.

	Implement sched_rr_get_interval syscall decoder.
	* linux/dummy.h (sys_sched_rr_get_interval): Remove.
	* linux/syscall.h (sys_sched_rr_get_interval): New prototype.
	* process.c (sys_sched_rr_get_interval): New function.

	Implement migrate_pages syscall decoder.
	* linux/dummy.h (sys_migrate_pages): Remove.
	* linux/syscall.h (sys_migrate_pages): New prototype.
	* mem.c (sys_migrate_pages): New function.

	Implement get_robust_list syscall decoder.
	* linux/dummy.h (sys_get_robust_list): Remove.
	* linux/syscall.h (sys_get_robust_list): New prototype.
	* process.c (sys_get_robust_list): New function.

	Define sys_set_robust_list as an alias to sys_munmap.
	* linux/dummy.h (sys_set_robust_list): Redefine to sys_munmap.

	Implement clock_adjtime syscall decoder.
	* linux/dummy.h (sys_clock_adjtime): Remove.
	* linux/syscall.h (sys_clock_adjtime): New prototype.
	* time.c (do_adjtimex): New function, based on sys_adjtimex.
	(sys_adjtimex): Use it.
	(sys_clock_adjtime): New function.

	Define sys_setns as an alias to sys_inotify_rm_watch.
	* linux/dummy.h (sys_setns): Redefine to sys_inotify_rm_watch.

	Sort definitions of dummy parsers.  No code changes.
	* linux/dummy.h: Sort definitions of parsers implemented as aliases.

	Correct inotify_rm_watch decoder.
	* file.c (sys_inotify_rm_watch): Print second argument as int.

	Alias sys_fsync to sys_close.
	* file.c (sys_fsync): Remove.
	* linux/syscall.h (sys_fsync): Likewise.
	* linux/dummy.h (sys_fsync): Alias to sys_close.
	* linux/m68k/syscallent.h: Add TD flag to fsync entry.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.

2012-03-10  Dmitry V. Levin  <ldv@altlinux.org>

	Update ioctl entries.
	* linux/ioctlent.h.in: Regenerate from v3.3 headers.
	* linux/i386/ioctlent.h.in: Likewise.

	strace-log-merge: cleanup.
	* strace-log-merge: Redirect usage to stderr, make the check
	for numeric suffix simpler.

	Add syscall entries for new linux syscalls.
	* linux/i386/syscallent.h: Update process_vm_writev handler.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/alpha/syscallent.h: Add entries for accept4 and sendmmsg.
	* linux/arm/syscallent.h: Add entries for process_vm_readv and
	process_vm_writev.
	* linux/m68k/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Add entries for process_vm_readv,
	process_vm_writev and accept4.
	* linux/microblaze/syscallent.h: Add entries for sendmmsg,
	process_vm_readv and process_vm_writev.

	Implement process_vm_writev decoder.
	* process.c (sys_process_vm_writev): New function.
	* linux/syscall.h (sys_process_vm_writev): New prototype.

	Output iovec length in vmsplice and process_vm_readv decoders.
	* io.c (sys_vmsplice): Output iovec length.
	* process.c (sys_process_vm_readv): Likewise.

2012-03-09  Dmitry V. Levin  <ldv@altlinux.org>

	swapon: decode swap flags.
	* file.c: Include <sys/swap.h>.
	(swap_flags): New xlat structure.
	(sys_swapon): New function.
	* linux/dummy.h (sys_swapon): Remove.
	* linux/syscall.h (sys_swapon): New declaration.

2012-03-09  Denys Vlasenko  <vda.linux@googlemail.com>

	Trivial simplification.
	* strace.c (detach): Use waitpid instead of wait4.

	Don't consider PROG to be our child in "strace -D PROG" case.
	TCB_STRACE_CHILD is used for the case when "strace PROG" is ^C-ed
	or something like that. strace should not just exit - it should
	do something with its child (such as signal it too).

	In -D case, PROG is not really a child of _strace_, it is a child
	of strace's parent. It's ok to handle it exactly as an attached process.

	While we are at it, remove nonsensical special-casing of TCB_STRACE_CHILD
	in printing of "<unfinished ...>" message.

	* strace.c (startup_attach): Don't set TCB_STRACE_CHILD if -D.
	(trace): Print "<unfinished ...>" on error regardless of TCB_STRACE_CHILD.

	Fix the case where we try to detach unattached processes.
	Before this change:
	$ strace -D -p1
	strace: -D and -p are mutually exclusive options
	Process 1 detached  <==== WRONG! (and we try to SIGSTOP it!!!)

	* defs.h: Change the meaning of TCB_ATTACHED: now it means "this tracee
	is attached to us". Add TCB_STRACE_CHILD: "this tracee is our child".
	* strace.c (kill_save_errno): Move up. No code changes.
	(process_opt_p_list): Don't set TCB_ATTACHED on new tcb.
	(startup_attach): Change how we work with TCB_ATTACHED.
	Set TCB_STRACE_CHILD on -D.
	(startup_child): Use kill_save_errno instead of kill.
	Set TCB_ATTACHED and TCB_STRACE_CHILD on attached strace child.
	If we are in -D case, don't set TCB_ATTACHED (we aren't attached yet).
	(detach): do not do PTRACE_DETACH if TCB_ATTACHED is not set.
	(cleanup): Check TCB_STRACE_CHILD instead of TCB_ATTACHED.
	(trace): Likewise.

	Call PTRACE_CONT with addr=0.
	* strace.c (trace): Call PTRACE_CONT with addr=0.

	install strace-log-merge by "make install"

	strace_log_merge: new file. Helper to merge timestamped strace -ff logs.

	Fix PID prefix printing in "strace -oLOG -ff -p1 -p2 -p3" case.
	In this case we were printing PIDs to LOG.* files
	even though it is not necessary.

	The fix is in the addition of "&& followfork < 2" condition.

	* strace.c: Remove pflag_seen variable, add print_pid_pfx one.
	(process_opt_p_list): Do not pflag_seen++.
	(main): Use "nprocs != 0" condition instead of "pflag_seen != 0".
	Set print_pid_pfx before entering main tracing loop.
	(printleader): Use print_pid_pfx to decide whether to print pid prefix.

	Allow -p PID to take comma or whitespace-separated list of PIDs.
	* defs.h: Clarify meaning of TCB_ATTACHED. No code changes.
	* strace.c (process_opt_p_list): New function.
	(main): Call process_opt_p_list to process -p PIDs argument.

2012-03-08  Denys Vlasenko  <vda.linux@googlemail.com>

	Pass addr=0 instead of 1 into restarting ptrace calls.
	While we are at it, fold do_ptrace into its lone caller.
	We no longer set tcp->ptrace_errno = ESRCH on ESRC error in upeek.
	Other code paths where ptrace fails wern't doing it, and the code which
	checks tcp->ptrace_errno even assumes it is never set to ESRCH.
	(It was me who added this code sometime ago, so it was my fault
	that it was a bit messy)

	I ran sigkill_rain test and verified that unfinished syscalls are
	still handled correctly.

	* util.c (ptrace_restart): Do not pass addr=1 to ptrace(), pass 0 instead.
	I have no idea why we were passing 1. Ptrace documentation says
	that addr parameter is ignored.
	(do_ptrace): Remove this function.
	(upeek): Use ptrace() instead of do_ptrace().
	* defs.h: Remove do_ptrace() declaration.

	Trivial tweaks to error messages.
	* strace.c (test_ptrace_setoptions_followfork): Use kill_save_errno
	instead of kill.
	(trace): Use perror_msg instead of perror.
	* count.c (set_sortby): Use error_msg_and_die instead of fprintf.
	* syscall.c (qualify): Likewise.
	* util.c (ptrace_restart): Expand error message.
	(umoven): Likewise.
	(umovestr): Likewise.
	(upeek): Use perror_msg instead of sprintf + perror.

2012-02-28  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove stray sys_swapon() declaration.
	* linux/syscall.h: Remove stray sys_swapon() declaration.
	* linux/mips/syscallent.h: Include dummy.h with correct relative path.
	* linux/dummy.h: Tweak one place where spaces are used instead of tabs.
	* linux/dummy_check.sh: New script. It helps in finding stray syscall
	handler declarations.

2012-02-27  Denys Vlasenko  <vda.linux@googlemail.com>

	Correct syscall entries for t[g]kill.
	* linux/hppa/syscallent.h: Make tgkill use sys_tgkill, not printargs.
	* linux/sh/syscallent.h: Change tkill type TD -> TS.
	* linux/sh64/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Change tkill type 0 -> TS.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.

	Assorted trivial optimizations.
	   text	   data	    bss	    dec	    hex	filename
	 236448	    672	  19044	 256164	  3e8a4	strace.before
	 236360	    672	  19044	 256076	  3e84c	strace

	* file.c (sprintmode): Use smaller static buffer, eliminate strlen call.
	(sprinttime): Use smaller static buffer.
	(printstat_sparc64): Coalesce two printing calls into one.
	(printstat_powerpc32): Likewise.
	(printcompat_statfs6): Likewise.
	(sys_utime): Do not fetch personality_wordsize[current_personality]
	repeatedly - cache it in local variable instead.
	* process.c (printargv): Likewise.
	* resource.c (sprintrlim): Return const char*, not char*. This allows
	to eliminate sprintf(buf, "RLIM_INFINITY"). Use smaller static buffer.
	(sprintrlim64): Likewise.
	* strace.c (strerror): Use smaller static buffer.
	(strsignal): Likewise.

	Alias a few more syscall printing functions.
	   text	   data	    bss	    dec	    hex	filename
	 237384	    672	  19044	 257100	  3ec4c	strace.before
	 236448	    672	  19044	 256164	  3e8a4	strace

	* defs.h: Declare new functions printargs_lu(), printargs_ld()
	which simply print syscall all args as unsigned or signed longs.
	* desc.c (sys_epoll_create): Call printargs_ld() instead of open-coding it.
	* linux/syscall.h: Remove declarations of the following functions:
	sys_alarm, sys_getresgid, sys_getsid, sys_nice, sys_setgid, sys_setpgid,
	sys_setpgrp, sys_setregid, sys_setresgid.
	* process.c (sys_setgid): Delete this function: now aliased to sys_setuid().
	(sys_getresgid): Delete this function: now aliased to sys_getresuid().
	(sys_setregid): Delete this function: now aliased to sys_setreuid().
	(sys_setresgid): Delete this function: now aliased to sys_setresuid().
	(sys_setpgrp): Delete this function: now aliased to printargs_lu().
	(sys_getsid): Likewise.
	(sys_setpgid): Likewise.
	(sys_alarm): Likewise.
	(sys_getpgrp): Delete this function: was unused - was already shadowed
	by a define in linux/dummy.h.
	(sys_setsid): Likewise.
	(sys_getpgid): Likewise.
	* resource.c (sys_nice): Delete this function: now aliased to printargs_ld().
	* linux/dummy.h: Define new aliases (see above for the list).
	* syscall.c (printargs_lu): New function.
	(printargs_ld): New function.

	Style fixes, no code changes.
	* desc.c (sys_io_getevents): Indentation fix.
	* file.c (sys_xstat): Remove space after function name.
	(decode_mknod): Indentation fix.
	* net.c (printsockopt): Indentation fix.
	* process.c (unalignctl_string): Indentation fix.
	(sys_sched_getscheduler): Remove space after ! operator.

2012-02-25  Dmitry V. Levin  <ldv@altlinux.org>

	Compress blank lines.
	Suppress repeated empty lines left after automated code removal.
	This change was made by filtering every source code file through
	"cat -s".

	Remove parts of automake machinery which are not needed on Linux.
	This change is a verbatim part of Dmitry's changes to remove support
	for non-Linux architectures.

	* Makefile.am: Don't install PORTING file. Install README-linux-ptrace file.
	Set OS variable to linux unconditionally.
	* configure.ac: Remove code to set opsys variable, and its usage.
	Remove checks for headers which are never present on Linux.
	* m4/stat.m4: Remove 'ifdef LINUX' check.
	* m4/statfs.m4: Likewise.

	Remove and update documentation.
	This change is a verbatim part of Dmitry's changes to remove support
	for non-Linux architectures.

	* PORTING: Deleted.
	* INSTALL: Modified.
	* README: Modified.
	* strace.1: Modified: bugs should be reported to mailing list, not Debian.
	* strace.spec: do not install PORTING file.

2012-02-25  Denys Vlasenko  <vda.linux@googlemail.com>

	Remove a few more code parts which are unused on Linux.
	This change is abapted from Dmitry's changes to remove support for
	non-Linux architectures.

	* Makefile.am: Remove if LINUX/endif pairs.
	* defs.h: Remove stream_ioctl() declaration.
	* ioctl.c (ioctl_decode): Remove 'ifdef HAVE_SYS_STREAM_H' block.
	* resource.c: Use 'defined(FOO)' instead of 'defined FOO' form.
	* util.c: Likewise.
	* signal.c: Remove conditional includes which are never used on Linux.
	* stream.c: Likewise.
	* file.c: Remove excessive empty lines.

	Build fixes after non-Linux code removal.
	* configure.ac: Remove calls to proc-based ptrace checks.
	* proc.c: Remove, it's empty now.
	* Makefile.am: Remove reference to proc.c.
	* net.c: Remove trailing newlines.
	* quota.c: Likewise
	* resource.c: Likewise
	* strace.c: Likewise
	* stream.c: Likewise
	* time.c: Likewise

	Fix defined(FOO) style.
	* file.c: Consistently use defined(FOO) instead of defined (FOO).
	* mem.c: Likewise.
	* net.c: Likewise.
	* signal.c: Likewise.
	* sock.c: Likewise.
	* linux/mips/syscallent.h: Likewise.

	Reindent preprocessor directives in util.c; fix style.
	* util.c: Fix indentation of preprocessor directives broken by
	automatic removal of non-Linux code. Fix style to use consistent
	defined(FOO) instead of defined (FOO).

	Reindent preprocessor directives in syscall.c; fix style.
	* syscall.c: Fix indentation of preprocessor directives broken by
	automatic removal of non-Linux code. Fix style to use consistent
	defined(FOO) instead of defined (FOO).

	Reindent defs.h preprocessor directives.
	* defs.h: Fix indentation of preprocessor directives broken by
	automatic removal of non-Linux code.

	Cleanup after non-Linux code removal.
	Conditions such as defined(LINUX) are always true now,
	defined(FREEBSD) etc are always false.
	When if directive has them as subexpressions, it can be simplified.
	Another trivial changes here are fixes for directive indentation.

	Manual removal of non-Linux source, documentation, etc.
	Remove non-Linux source directories: freebsd/, svr4/, sunos4/, svr4/.
	Remove README-freebsd, README-sunos4, README-svr4, m4/procfs.m4.

	linux/sparc/{errnoent1,ioctlent1,signalent1}.h used to point to svr4/ files -
	replace their contents with copies of used (and now deleted) files.
	Make linux/sparc64/{errnoent1,ioctlent1,signalent1}.h include these files
	instead of svr4/* ones.

	Makefile.am: remove references to deleted files.
	configure.ac: Remove a few tests which make no sense on Linux.
	Man page: remove non-Linux quirks information.

	Automated removal of non-Linux code.
	This change is generated by running every source through the following command:

	unifdef -DLINUX -Dlinux -USUNOS4 -USVR4 -UUNIXWARE -UFREEBSD
	-USUNOS4_KERNEL_ARCH_KLUDGE -UHAVE_MP_PROCFS
	-UHAVE_POLLABLE_PROCFS -UHAVE_PR_SYSCALL -UUSE_PROCFS file.c

2012-02-24  Denys Vlasenko  <vda.linux@googlemail.com>

	When accessing data blocks, truncate addr to wordsize.
	* util.c (umoven): Truncate addr to wordsize before use.

2012-02-22  Dmitry V. Levin  <ldv@altlinux.org>

	strace.1: fix a typo.
	* strace.1: Fix a typo in example description.
	This fixes Debian bug #653309.

	Fix sockaddr_un.sun_path name in decoded output.
	* net.c (printsock): Show sockaddr_un.sun_path as "sun_path".
	This fixes Debian bug #554946.

	Avoid potential core file clobbering on exit.
	* strace.c (main): Set RLIMIT_CORE to zero before terminating itself
	with a deadly signal.
	This fixes Debian bug #656398.

2012-02-20  Dmitry V. Levin  <ldv@altlinux.org>

	Eliminate native_scno and known_scno.
	* defs.h (known_scno): Remove.
	(sysent): Remove native_scno field.
	* process.c [IA64]: Replace known_scno(tcp) with tcp->scno.
	(internal_fork) [USE_PROCFS || !LINUX]: Likewise.
	* syscall.c: Do not define NR_SYSCALL_BASE.
	(known_scno): Remove.
	(syscall_fixup_on_sysenter) [USE_PROCFS]: Replace known_scno(tcp)
	with tcp->scno.
	(trace_syscall_entering) [SVR4 || FREEBSD || SUNOS4]: Likewise.
	(syscall_fixup_on_sysexit) [SUNOS4]: Likewise.

	Remove initialization of native_scno field.
	* linux/i386/syscallent.h: Remove native_scno initialization for clone,
	fork and vfork.
	* linux/ia64/syscallent.h (sys_fork, sys_vfork): Remove redirections
	to printargs.
	* linux/syscall.h [IA64]: Do not define SYS_fork and SYS_vfork.
	* util.c (printcall) [IA64]: Likewise.
	(setbpt): Use sys_func to check for clone, fork and vfork syscalls.

	Do not use SYS_ipc and SYS_socketcall.
	* linux/dummy.h (sys_ipc, sys_socketcall): Remove redirections to
	printargs.
	* linux/ia64/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Remove native_scno initialization for "ipc"
	and "socketcall".
	* linux/syscall.h (sys_ipc, sys_socketcall): New prototypes.
	(SYS_ipc, SYS_socketcall): Remove no longer used constants.
	[IA64]: Remove undefining of ipc and socket SYS_* constants.
	[SPARC || SPARC64]: Remove unused ipc SYS_* constants.
	* ipc.c (sys_ipc): New function.
	* sock.c (sys_socketcall): Likewise.
	* syscall.c (trace_syscall_entering): Use sys_func to check for ipc and
	socket subcalls.

	Remove initialization of native_scno field for most of syscalls.
	The native_scno field is not so much used in the code than before.
	In many cases sys_func is checked instead, and for most of syscall
	entries there is no need to initialize native_scno.

	* linux/i386/syscallent.h: Remove native_scno initialization for
	_exit, read, write, waitpid, execve, wait4, sysfs, readv, writev,
	pread64, pwrite64, exit_group, waitid, send, recv, sendto and
	recvfrom syscall entries.
	* linux/syscall.h: Do not define no longer used SYS_waitid and
	SYS_sub_* constants.
	[IA64]: Do not define SYS_waitpid and SYS32_* constants.
	* defs.h: Do not define no longer used  __NR_exit_group constant.
	* strace.c [USE_PROCFS] (proc_open): Use sys_func to check for execve.

2012-02-14  Mike Frysinger  <vapier@gentoo.org>

	util: check for process_vm_readv in C library.
	glibc-2.15 provides process_vm_readv, so trying to provide it ourselves
	with that version fails.

	* configure.ac (AC_CHECK_FUNCS): Add process_vm_readv.
	* util.c: Handle HAVE_PROCESS_VM_READV.

2012-02-09  Denys Vlasenko  <vda.linux@googlemail.com>

	README-linux-ptrace: correct the description of suppressed signals.

2012-02-06  Dmitry V. Levin  <ldv@altlinux.org>

	strace -P: fix handling of invalid syscalls.
	* pathtrace.c (pathtrace_match): Check the given syscall number using
	SCNO_IN_RANGE.

2012-02-06  H.J. Lu  <hongjiu.lu@intel.com>

	Skip the syscall entry if the sys_func field is NULL.
	Avoid NULL dereference when there are holes in sysent tables.
	It can happen with syscall (number, ...) and number is in those holes.
	There are no targets with holey systent tables so far, but at least
	one such a target, x32, is already on the horizon.

	* defs.h (SCNO_IN_RANGE): Also check the sys_func field.

	Define RLIM64_INFINITY only if not defined.
	* resource.c (RLIM64_INFINITY): Define only if it isn't defined.

	Cast to long for %l in printf.
	Cast a value to long for %l in printf to avoid compiler warning
	on systems where it may be long long.

	* count.c (call_summary_pers): Cast to long.
	* ipc.c (sys_mq_open, printmqattr): Likewise.
	* quota.c (decode_cmd_data): Likewise.
	* resource.c (sys_sysinfo): Likewise.
	* time.c (tprint_timex): Likewise.

	Check HAVE_LONG_LONG_OFF_T when printing offset.
	When HAVE_LONG_LONG_OFF_T is defined, we need to use %llu to print
	offset.

	* io.c (sys_sendfile): Check HAVE_LONG_LONG_OFF_T when printing
	offset.

	Define old stat functions only if needed.
	When HAVE_LONG_LONG_OFF_T is defined, those old stat functions aren't
	used and strace won't link since they use realprintstat which isn't
	defined when HAVE_LONG_LONG_OFF_T is defined.

	* file.c (convertoldstat, sys_oldstat, sys_oldfstat, sys_oldlstat):
	Define only if HAVE_LONG_LONG_OFF_T isn't defined.

	Print NULL for zero address in sys_mmap64.
	* mem.c (sys_mmap64): Print NULL for zero address so that it is
	consistent with sys_mmap.

2012-02-04  Dmitry V. Levin  <ldv@altlinux.org>

	Remove unused sys_pread64 and sys_pwrite64 parsers on Linux.
	* io.c [HAVE_LONG_LONG_OFF_T]: Remove sys_pread64 and sys_pwrite64
	aliases.
	(sys_pread64, sys_pwrite64): Define these functions only on
	[SVR4 && _LFS64_LARGEFILE] platform.
	* linux/mips/syscallent.h: Use sys_pread and sys_pwrite to handle
	appropriate syscalls.
	* linux/syscall.h (sys_pread64, sys_pwrite64): Remove.
	* syscall.c (dumpio): Check sys_pread64 and sys_pwrite64 only on
	[SVR4 && _LFS64_LARGEFILE] platform.

2012-02-03  Denys Vlasenko  <vda.linux@googlemail.com>

	Trivial changes to help text. No code changes.
	* strace.c (usage): Tweak help text: remove unpaired closing brackets,
	make -V and -h sit on separate lines (hard to see them otherwise).

2012-01-29  Denys Vlasenko  <vda.linux@googlemail.com>

	Simple optimizations.
	   text	   data	    bss	    dec	    hex	filename
	 239474	    672	  20484	 260630	  3fa16	strace.before
	 239234	    668	  19044	 258946	  3f382	strace

	* file.c (sprint_open_modes): Reduce static buffer size.
	Simplify separator printing.
	* signal.c (sprintsigmask): Reduce static buffer size.
	Simplify separator printing and printing of almost full masks.
	Use stpcpy instead of sprintf and strcpy+strlen.
	* strace.c (startup_child): Don't strchr() for ':' twice in a row.
	* util.c (sprintflags): Exit loop early if possible.

	Trivial optimization.
	* strace.c (cleanup): Read 'interrupted' volatile variable only once.

	Make interactive-ness directly controllable via command line option.
	Defaults are often ok, but when they are not, people get confused.
	"Why can't I kill strace?" and "Why strace dies on ^C when I want
	to _tracee_ to die instead?" are typical complaints.

	* strace.c: Replace 'interactive' variable with 'opt_intr' variable.
	Define INTR_foo constants for its possible values.
	Define 'interactive' as a macro.
	(usage): Document -I n option.
	(main): Parse -I n option, modify signal handling to accomidate new
	-I 1 and -I 4 modes.

	Suppress compiler warning.
	* strace.c (trace): Frame potentially unused label with ifdef/endif.

	On Ctrl-C induced detach, send SIGINT to child tracee, not SIGTERM.
	* strace.c (interrupt): Remember signal number.
	(cleanup): If we exiting due to signal, send that signal to child tracee.

	Add experimental code to use PTRACE_SEIZE, disabled by default.
	All new code is predicated on "ifdef USE_SEIZE". If it is not defined,
	behavior is not changed.

	If USE_SEIZE is enabled and run-time check shows that PTRACE_SEIZE works, then:
	- All attaching is done with PTRACE_SEIZE + PTRACE_INTERRUPT.
	  This means that we no longer generate (and possibly race with) SIGSTOP.
	- PTRACE_EVENT_STOP will be generated if tracee is group-stopped.
	  When we detect it, we issue PTRACE_LISTEN instead of PTRACE_SYSCALL.
	  This leaves tracee stopped. This fixes the inability to SIGSTOP or ^Z
	  a straced process.

	* defs.h: Add commented-out "define USE_SEIZE 1" and define PTRACE_SEIZE
	and related constants.
	* strace.c: New variable post_attach_sigstop shows whether we age going
	to expect SIGSTOP on attach (IOW: are we going to use PTRACE_SEIZE).
	(ptrace_attach_or_seize): New function. Uses PTRACE_ATTACH or
	PTRACE_SEIZE + PTRACE_INTERRUPT to attach to given pid.
	(startup_attach): Use ptrace_attach_or_seize() instead of ptrace(PTRACE_ATTACH).
	(startup_child): Conditionally use alternative attach method using PTRACE_SEIZE.
	(test_ptrace_setoptions_followfork): More robust parameters to PTRACE_TRACEME.
	(test_ptrace_seize): New function to test whether PTRACE_SEIZE works.
	(main): Call test_ptrace_seize() while initializing.
	(trace): If PTRACE_EVENT_STOP is seen, restart using PTRACE_LISTEN in order
	to not let tracee run.
	* process.c: Decode PTRACE_SEIZE, PTRACE_INTERRUPT, PTRACE_LISTEN.
	* util.c (ptrace_restart): Add "LISTEN" to a possible error message.

2012-01-28  Denys Vlasenko  <vda.linux@googlemail.com>

	process_vm_readv gets EINVAL if process is gone (SIGKILLed). Don't complain.
	* util.c (umoven): Don't complain on EINVAL from process_vm_readv.
	(umovestr): Likewise.

	Revert last change. Add a comment to prevent further misunderstanding.
	* time.c (sys_nanosleep): Display remaining time only on interrupt.

	Fix nanosleep decoding: second argument was not shown after success.
	* time.c (sys_nanosleep): Fix bug - inverted is_restart_error() check.
	* syscall.c (is_restart_error): Remove redundant check.

	Use process_vm_readv instead of PTRACE_PEEKDATA to read data blocks.
	Currently, we use PTRACE_PEEKDATA to read things like filenames and
	data passed by I/O syscalls.
	PTRACE_PEEKDATA gets one word per syscall. This is VERY expensive.
	For example, in order to print fstat syscall, we need to perform
	more than twenty trips into kernel to fetch one struct stat!

	Kernel 3.2 got a new syscall, process_vm_readv(), which can be used to
	copy data blocks out of process' address space.

	This change uses it in umoven() and umovestr() functions if possible,
	with fallback to old method if process_vm_readv() fails.
	If it returns ENOSYS, we don't try to use it anymore, eliminating
	overhead of trying it on older kernels.

	Result of "time strace -oLOG ls -l /usr/lib >/dev/null":
	before patch: 0.372s
	After patch:  0.262s

	* util.c (process_vm_readv): Wrapper to call process_vm_readv syscall.
	(umoven): Use process_vm_readv for block reads of tracee memory.
	(umovestr): Likewise.
	* linux/syscall.h: Declare new function sys_process_vm_readv.
	* process.c (sys_process_vm_readv): Decoder for new syscall.
	* linux/i386/syscallent.h: Add process_vm_readv, process_vm_writev syscalls.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.

	Fix a case of broken output if last seen syscall was exit.
	* defs.h: Rename tcp_last to printing_tcp. Explain what it means.
	Remove printtrailer() function.
	* process.c (sys_exit): Convert printtrailer() call to "printing_tcp = NULL".
	* strace.c: Add new variable printing_tcp.
	(cleanup): Convert printtrailer() call to "printing_tcp = NULL".
	(trace): Likewise.
	(trace): Fix checks for incomplete line - it was working wrongly if last syscall was exit.
	(printleader): Set printing_tcp.
	(printtrailer): Remove this function.
	* syscall.c: Remove tcp_last variable.
	(trace_syscall_entering): Don't set printing_tcp, printleader call now does it.
	(trace_syscall_exiting): Convert printtrailer() call to "printing_tcp = NULL".

	Fix handling of test/threaded_execve.c testcase.
	Since 3.0, Linux has a way to identify which thread execve'ed.
	This patch makes use of it in order to properly dispose
	of disappeared ("superseded") thread leader,
	and replace it with execve'ed thread.

	Before this patch, strace was "leaking" thread which exec'ed.
	It was thinking that it still runs. It would look like this:

	18460 pause( <unfinished ...>     <=== thread leader
	18466 execve("/proc/self/exe", ["exe", "exe"], [/* 47 vars */] <unfinished ...>
	18465 +++ exited with 0 +++       <=== exits from other threads
	18460 <... pause resumed> )             = 0

	The last line is wrong: it's not pause resumed, it's execve resumed.
	If thread leader would do exit instead of pause, it is much worse:
	strace panics because it thinks it sees return from exit syscall!

	And strace isn't aware 18466 (exec'ed thread) is gone.
	It still thinks it's executes execve syscall.

	* strace.c: New variable "static char *os_release".
	(get_os_release): New static function.
	(main): Call get_os_release to retrieve Linux version.
	(trace): If we see PTRACE_EVENT_EXEC, retrieve old pid, and if it
	differs from new one, free one of tcbs and print correct messages.

2012-01-27  Denys Vlasenko  <vda.linux@googlemail.com>

	Fix readlink result display - was printing bogus "..." semi-randomly.
	* file.c (decode_readlink): Use printstr() instead of printpathn().

	Add new test program: test/threaded_execve.c.

	Make pid2tcb static.
	* defs.h: Remove pid2tcb declaration.
	* strace.c (pid2tcb): Make this function static.

2012-01-24  Denys Vlasenko  <vda.linux@googlemail.com>

	Per Dmitry's request, remove paranoid check in verror_msg()
	* strace.c (verror_msg): Remove redundant check for msg != NULL.

	More robust error check for vasprintf.
	* strace.c (verror_msg): More robust error check for vasprintf.

	Slightly more compact handling of argv[]
	   text	   data	    bss	    dec	    hex	filename
	 238274	    672	  20484	 259430	  3f566	strace.before
	 238226	    672	  20484	 259382	  3f536	strace

	* strace.c (main): Slightly more compact handling of argv[]

	Trivial optimization.
	* strace.c: Set default interactive = 1 statically instead
	of doing it in main().

	Allocate -o OUTFILE buffer only if needed.
	   text	   data	    bss	    dec	    hex	filename
	 238258	    668	  28676	 267602	  41552	strace.before
	 238274	    668	  20484	 259426	  3f562	strace

	* strace.c (main): Allocate -o OUTFILE buffer only if needed:
	unused buffer in bss is not entirely free.

	Use single fprintf in verror_msg()
	This change partially reverts commit 44d0532.

	In code before commit 44d0532, single fprintf was used on purpose:
	we want to send entire message as one write() call. Since stderr
	is unbuffered, separate fprintf's to it always result in separate
	writes, they are not coalesced. If we aren't the only program
	which writes to this particular stderr, this may result
	in interleaved messages.

	Since this function is not performance critical, I guess
	it's ok to make it less efficient.

	* strace.c (verror_msg): Attempt to print the message in single
	write operation. Use separate fprintfs as a fallback if malloc fails.

2012-01-21  Denys Vlasenko  <vda.linux@googlemail.com>

	Improve code readability (logic is unchanged)
	* util.c (umoven): Move assignment out of function call. Make assignment
	to a flag variable later, closer to the place where it will be used.
	(umovestr): Likewise.
	(uload): Likewise.

2012-01-20  Denys Vlasenko  <vda.linux@googlemail.com>

	Change umovestr API: return > 0 instead of 0 if NUL was seen.
	* pathtrace.c (upathmatch): Adjust umovestr return value check for new API.
	* util.c (printpathn): Use umovestr() > 0 return value for more efficient
	(and robust - we don't depend on "no overwrote past NUL" behavior anymore)
	handling of terminating NUL.
	(printstr): Remove useless NUL placement before umovestr() call.
	Allocate 1 byte more to outstr[] array - for NUL.
	(umovestr): Change to return 1 if NUL was seen.

	umovestr result may have no NUL, use "%.*s" instead of "%s" to print it.
	* system.c (sys_mount): Be careful when printing umovestr result,
	it may have no terminating NUL.
	(sys_sysmips): Likewise.

	Eliminate code duplication in time printing, reduce a few static buffers
	   text	   data	    bss	    dec	    hex	filename
	 238454	    664	  28772	 267890	  41672	strace.before
	 238106	    664	  28676	 267446	  414b6	strace

	* defs.h: Add TIMESPEC_TEXT_BUFSIZE and TIMEVAL_TEXT_BUFSIZE defines.
	Add 'int special' parameter to sprinttv().
	* time.c (sprinttv): Add 'int special' parameter, and use it
	similarly to 'int special' parameter of printtv_bitness().
	(printtv_bitness): Use sprinttv() instead of duplicating its code.
	(print_timespec): Use sprint_timespec() instead of duplicating
	its code.
	* desc.c (decode_select): Use TIMEVAL_TEXT_BUFSIZE instead of 128
	when checking remaining buffer size.
	* net.c (sys_recvmsg): Use TIMESPEC_TEXT_BUFSIZE instead of 128
	for static buffer size.
	* stream.c (decode_poll): Use TIMESPEC_TEXT_BUFSIZE instead of 128
	when checking remaining buffer size.

2012-01-19  Denys Vlasenko  <dvlasenk@redhat.com>

	Reduce bss usage and speed up string printing.
	   text	   data	    bss	    dec	    hex	filename
	 237913	    660	  49284	 287857	  46471	strace.before
	 237973	    660	  28772	 267405	  4148d	strace

	This reduces L1 D-cache pressure a bit: instead of dirtying
	20k of bss, we will reuse already dirty stack area.

	* util.c (printpathn): Use on-stack buffers instead of static ones.
	Saves 5*MAXPATHLEN in bss.
	(printstr): Use tprints() instead of tprintf("%s") when printing
	formatted string. May be a bit faster, depending on libc.

2012-01-18  Andreas Schwab  <schwab@linux-m68k.org>

	Add support for compat_statfs64.
	* file.c (struct compat_statfs64, printcompat_statfs64): Define.
	(sys_statfs64, sys_fstatfs64): Use it.

	Add support for statfs64.f_flags.
	* file.c (printstatfs64): Print f_flags if available.

	Fix missing parens.
	* signal.c (sys_sigreturn): Add missing parens.

2012-01-18  Denys Vlasenko  <dvlasenk@redhat.com>

	Get rid of TCB_SIGTRAPPED.
	On attempts to block or set SIGTRAP handler,
	for example, using sigaction syscall, we generate
	an additional SIGSTOP.

	This change gets rid of this SIGSTOP sending/ignoring.
	It appears to work just fine.

	It also works if I force strace to not use PTRACE_O_TRACESYSGOOD,
	which means strace stops will be marked with SIGTRAP,
	not (SIGTRAP | 0x80) - I wondered maybe that's when
	this hack is needed.

	So, why we even have TCB_SIGTRAPPED? No one knows. It predates
	version control: this code was present in the initial commit,
	in 1999. No adequate comments, either.

	Moreover, TCB_SIGTRAPPED is not set in sys_rt_sigaction
	and sys_sigprocmask syscalls - the ones which are most usually
	used to implement signal blocking, it is only set in obsolete
	sys_signal, sys_sigaction, sys_sigsetmask, and in some dead
	non-Linux code.

	I think whatever bug it was fixing is gone long ago -
	at least as long as sys_rt_sigaction is used by glibc.
	Again, since glibc (and uclibc) uses sys_rt_sigaction
	and sys_sigprocmask, modified code paths are not used
	by most programs anyway.

	* defs.h: Remove definition of TCB_SIGTRAPPED.
	* signal.c (sys_sigvec): Don't set TCB_SIGTRAPPED and don't send SIGSTOP.
	(sys_sigsetmask): Likewise.
	(sys_sigaction): Likewise.
	(sys_signal): Likewise.
	* strace.c (trace): Remove code which executes if TCB_SIGTRAPPED is set.

	When we write log, flush output buffers in a few more cases.
	I observed a case when signal delivery message was buffered
	by stdio until it was flushed along with the next syscall
	entry message.

	* strace.c (trace): Flush output buffers in a few more cases.

	Fix old sigaction display.
	* signal.c (sys_sigaction): Fix display of sigaction with
	SIG_DFL/SIG_IGN handlers.

	Change x86_64_regs struct type from pt_regs to user_regs_struct.
	* syscall.c: Change x86_64_regs struct type from
	pt_regs to user_regs_struct, and explain the change in comment.

2012-01-17  Dmitry V. Levin  <ldv@altlinux.org>

	Fix struct pt_regs declaration on i386 and x86-64.
	* defs.h [I386] (i386_regs): Replace definition with declaration.
	[X86_64] (x86_64_regs): Remove.
	* syscall.c [X86_64] (x86_64_regs): Make static.

2012-01-12  Denys Vlasenko  <dvlasenk@redhat.com>

	Make ERESTARTxyz messages more descriptive.
	There is widespread confusion about exact meaning
	of ERESTARTxyz codes. Before this change, we were showing
	all four of them the same: as "(To be restarted)".

	This change prints better explanations for these codes,
	and contains verbose comments which explain *why* we display
	codes that way - or else someone confused
	is bound to come later and mangle them again.
	New messages are:

	ERESTARTSYS (To be restarted if SA_RESTART is set)
	ERESTARTNOINTR (To be restarted)
	ERESTARTNOHAND (Interrupted by signal)
	ERESTART_RESTARTBLOCK (Interrupted by signal)

	* syscall.c (trace_syscall_exiting): Make ERESTARTxyz messages
	more descriptive.

2012-01-10  Denys Vlasenko  <dvlasenk@redhat.com>

	Fix sigreturn arg count from 1 to 0 on all architectures.
	* linux/alpha/syscallent.h: Change [rt_]sigreturn's arg count to 0.
	* linux/arm/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.

	Display mask on enter to sigreturn, not on exit.
	sys_sigreturn() performs ugly manipulations in order to show
	signal mask which is restored by this syscall: on syscall entry,
	fetches it from the stack, saves it in tcp->u_arg[]
	(where it used to overflow this array - fixed sometime ago),
	then retrieves the mask and displays it on syscall exit.

	Apparently, the motivation is to make it slightly more obvious
	to user that signal mask is restored only when this syscall returns.
	IMO, this hardly justifies the necessary hacks. It is much easier
	to display the mask at the point when we fetch it - on syscall entry.

	While at it, I made it so that we do display returned value/errno.
	I see no point in hiding it and showing uninformative "= ?" instead.

	Example of pause() being interrupted by ALRM which has installed handler
	which re-arms ALRM:

	Before the patch:

	rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
	--- {si_signo=SIGALRM, si_code=SI_KERNEL} (Alarm clock) ---
	alarm(1)                                = 0
	sigreturn()                             = ? (mask now [INT])

	After:

	rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
	--- {si_signo=SIGALRM, si_code=SI_KERNEL} (Alarm clock) ---
	alarm(1)                                = 0
	sigreturn() (mask [INT])                = -1 EINTR (Interrupted system call)

	* defs.h: Declare struct pt_regs i386_regs and struct pt_regs x86_64_regs.
	* syscall.c: Remove "static" keywork from these structures' definitions.
	* signal.c (sys_sigreturn): Display mask on enter, not on exit.

2012-01-04  Denys Vlasenko  <dvlasenk@redhat.com>

	Do not detach from tracee which experienced ptrace error.
	Before this patch, if a thread got nuked by exit in another thread
	and we happened to poke it at the same time, we print "????(" thingy
	and detach the thread. Since we removed "detach before death" logic,
	this no longer matches the behavior of other threads.
	Before patch:
	[pid  1780] exit_group(1)               = ?
	[pid  1778] ????( <unfinished ...>
	Process 1778 detached
	[pid  5860] +++ exited with 1 +++
	After:
	[pid 17765] exit_group(1)               = ?
	[pid 21680] ????( <unfinished ...>
	[pid 17791] +++ exited with 1 +++
	[pid 21680] +++ exited with 1 +++

	* strace (trace): Do not detach from tracee which experienced ptrace error.

	Remove sig parameter from detach()
	* strace.c (detach): Drop sig parameter - it is zero in all calls.
	(cleanup): Don't pass sig = 0 to detach() call.
	(detach): Ditto.

2011-12-26  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance decoding for personalities with small wordsize.
	* util.c (umoven, umovestr) [SUPPORTED_PERSONALITIES > 1]: If current
	personality's wordsize is less than sizeof(long), use only significant
	bits of the given address.

2011-12-23  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance personality switching.
	On syscall entry, save current personality in the tcb structure
	along with scno.
	On syscall exit, restore current personality from the tcb structure.
	* defs.h (struct tcb) [SUPPORTED_PERSONALITIES > 1]: Add currpers
	field.
	* strace.c (alloc_tcb) [SUPPORTED_PERSONALITIES > 1]: Initialize
	tcp->currpers.
	* syscall.c (update_personality) [SUPPORTED_PERSONALITIES > 1]: New
	function.
	(get_scno, trace_syscall_exiting): Use it.

	Reported-by: Michael A Fetterman <mafetter@nvidia.com>

2011-12-01  Dmitry V. Levin  <ldv@altlinux.org>

	* net.c (socktcpoptions): Add more TCP_* constants from linux/tcp.h.
	Reported-by: Rick Jones <rick.jones2@hp.com>

2011-12-01  Heiko Carstens  <heiko.carstens@de.ibm.com>

	Fix sys_ipc/sys_semtimedop decoding on s390.
	The s390 kernel sys_ipc system call only takes five arguments instead of
	six arguments which the common code sys_ipc implementation takes.
	One of the arguments of the sys_semtimedop subcall is therefore passed in
	a different register than in the common code implementation.
	This leads to broken decoding of the timespec argument:

	semtimedop(0, 0x3ffffb43832, 1, {...})  = -1 EAGAIN

	Fixed it looks like this:

	semtimedop(0, 0x3ffffc2c842, 1, {0, 10000000}) = -1 EINTR

	* linux/ipc.c (sys_semtimedop): Fix timespec decoding on s390.

2011-11-29  Dmitry V. Levin  <ldv@altlinux.org>

	strace.c (trace): Fix compilation warning.

2011-11-28  Dmitry V. Levin  <ldv@altlinux.org>

	linux/syscall.h: Remove redundant function declarations.
	Remove 51 function declarations aliased to other declarations in
	linux/dummy.h file.

	linux/syscall.h: Sort function declarations.

	linux/syscall.h: Place one function declaration per line.

	Remove redundant parsers.
	* desc.c (sys_dup): Remove.
	* file.c (sys_pivotroot, sys_rmdir, sys_fchdir, sys_chroot, sys_fchroot,
	sys_unlink, sys_symlink, sys_rename): Remove.
	* linux/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_pivotroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
	* linux/dummy.h: Add aliases for sys_chroot, sys_dup, sys_pivotroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink.
	* pathtrace.c (pathtrace_match): Update.
	* sunos4/dummy.h: Add aliases for sys_chroot, sys_dup, sys_fchdir,
	sys_fchroot, sys_rename, sys_rmdir, sys_symlink, sys_unlink.
	* svr4/dummy.h: Likewise.
	* sunos4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.
	* svr4/syscall.h (sys_chroot, sys_dup, sys_fchdir, sys_fchroot,
	sys_rename, sys_rmdir, sys_symlink, sys_unlink): Remove.

	Reflect the fact that nfsservctl syscall was removed from linux kernels.
	linux/dummy.h: Move nfsservctl to "unimplemented" section.

2011-11-27  Dmitry V. Levin  <ldv@altlinux.org>

	x86_64: add getcpu syscall entry.
	* linux/x86_64/syscallent.h: Add syscall entry for getcpu.

2011-11-26  Dmitry V. Levin  <ldv@altlinux.org>

	Add syscall entries for new linux syscalls.
	* linux/dummy.h: Add printargs parsers for new syscalls.
	* linux/arm/syscallent.h: Add entries for sys_clock_adjtime,
	sys_name_to_handle_at, sys_open_by_handle_at, sys_sendmmsg, sys_setns
	and sys_syncfs.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/alpha/syscallent.h: Add entries for sys_clock_adjtime,
	sys_name_to_handle_at, sys_open_by_handle_at, sys_setns and sys_syncfs.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Add entry for sys_setns.
	* linux/bfin/syscallent.h: Add entries for sys_sendmmsg and sys_setns.
	* linux/hppa/syscallent.h: Add entries for sys_clock_adjtime,
	fanotify_init, fanotify_mark, sys_name_to_handle_at,
	sys_open_by_handle_at, sys_sendmmsg, sys_setns and sys_syncfs.

	Fix prctl syscall entries.
	* linux/mips/syscallent.h: Fix prctl handler.
	* linux/tile/syscallent.h: Likewise.

	arm: fix io_* syscall entries.
	* linux/arm/syscallent.h: Fix handlers for io_setup, io_destroy,
	io_getevents, io_submit and io_cancel.

	Fix mincore syscall entries.
	* linux/arm/syscallent.h: Fix mincore handler.
	* linux/avr32/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.

2011-11-25  Dmitry V. Levin  <ldv@altlinux.org>

	Fix sendmsg syscall entries.
	* linux/arm/syscallent.h: Fix number of sendmsg arguments.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix epoll_wait syscall entries.
	* linux/arm/syscallent.h: Fix epoll_wait flags and handler.
	* linux/m68k/syscallent.h: Fix epoll_wait flags.
	* linux/microblaze/syscallent.h: Fix number of epoll_wait arguments.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix epoll_ctl syscall entries.
	* linux/arm/syscallent.h: Fix epoll_ctl flags and handler.
	* linux/m68k/syscallent.h: Fix epoll_ctl flags.
	* linux/x86_64/syscallent.h: Fix number of epoll_ctl arguments.

	arm: fix epoll_create syscall entry.
	* linux/arm/syscallent.h: Fix epoll_create handler.

	Fix mlockall syscall entries.
	* linux/arm/syscallent.h: Fix number of mlockall arguments.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix epoll_pwait syscall entries.
	* linux/alpha/syscallent.h: Fix number of epoll_pwait arguments.
	* linux/arm/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix reboot syscall entries.
	* linux/alpha/syscallent.h: Fix number of reboot arguments.
	* linux/arm/syscallent.h: Likewise.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

	Fix swapon syscall entries.
	* linux/arm/syscallent.h: Fix number of swapon arguments.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/alpha/syscallent.h: Fix number of swapon arguments, add TF flag.
	* linux/hppa/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.

	Fix sgetmask and ssetmask syscall entries.
	* linux/hppa/syscallent.h: Fix sgetmask and ssetmask entries.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/tile/syscallent.h: Likewise.

	Rename siggetmask to sgetmask and sigsetmask to ssetmask.
	* linux/arm/syscallent.h: Rename siggetmask to sgetmask and
	sigsetmask to ssetmask.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Rename sys_sgetmask to sys_siggetmask,
	sys_ssetmask to sys_sigsetmask.

	Add TRACE_IPC flag to sys_ipc syscall entries.
	* linux/arm/syscallent.h: Add TI flag to sys_ipc entry.
	* linux/avr32/syscallent.h: Likewise.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.

2011-11-05  Dmitry V. Levin  <ldv@altlinux.org>

	gitlog-to-changelog: update from gnulib.
	* gitlog-to-changelog: Update from gnulib.
	* Makefile.am: Add --append-dot to gitlog-to-changelog invocation.

2011-10-22  Denys Vlasenko  <dvlasenk@redhat.com>

	Decode TIOCSCTTY's third parameter.
	* term.c (term_ioctl): Decode TIOCSCTTY's third parameter.

2011-10-14  Dmitry V. Levin  <ldv@altlinux.org>

	Remove useless and obsolete "#if DONE" sections.  No code changes.
	* linux/dummy.h: Remove "#if DONE" section.
	* linux/sparc/dummy2.h: Likewise.
	* linux/sparc64/dummy2.h: Likewise.
	* sunos4/dummy.h: Likewise.
	* svr4/dummy.h: Likewise.

	Add names for dummy parsers.  No code changes.
	* linux/dummy.h: Add aliases to printargs() for those of dummy parsers
	that had no own names before.
	* linux/*/syscallent.h: Use these new names instead of printargs.

	Sort definitions of dummy parsers.  No code changes.
	* linux/dummy.h: Sort definitions of parsers implemented as aliases
	to printargs().

2011-10-14  Mike Frysinger  <vapier@gentoo.org>

	sys_epoll_create1: decode flag arguments correctly.
	* desc.c (epollflags): Define.
	(sys_epoll_create1): Use epollflags to printflags. Change "O" to "EPOLL".

	Reported-by: Марк Коренберг <socketpair@gmail.com>

2011-10-11  Dmitry V. Levin  <ldv@altlinux.org>

	Implement decoding of splice, tee and vmsplice(2) syscalls.
	* io.c (print_loff_t): New function.
	(sys_sendfile64): Use it.
	(splice_flags): New xlat structure.
	(sys_tee, sys_splice, sys_vmsplice): New functions.
	* linux/syscall.h (sys_tee, sys_splice, sys_vmsplice): Declare them.
	* linux/*/syscallent.h: Use them.

	Fix epoll_wait and epoll_pwait decoding.
	* desc.c (epoll_wait_common): Print "maxevents" and "timeout" arguments
	as integers.

	Reported-by: Марк Коренберг <socketpair@gmail.com>

	Decode EPOLLRDHUP.
	* desc.c (epollevents): Add EPOLLRDHUP.

	Reported-by: Марк Коренберг <socketpair@gmail.com>

	Remove unreachable code in umoven() and umovestr().
	* util.c (umoven, umovestr): Remove unreachable code.

	Reported-by: Weichuan Yan <wchyan@marvell.com>

2011-09-05  Denys Vlasenko  <dvlasenk@redhat.com>

	Do post-attach initialization earlier; fix "we ignore SIGSTOP on NOMMU" bug
	We set ptrace options when we see post-attach SIGSTOP.
	This is wrong: it's better to set them right away on the very first
	stop (whichever it will be). It also will make adding SEIZE support easier,
	since SEIZE has no post-attach SIGSTOP.

	We do it by adding a new bit, TCB_IGNORE_ONE_SIGSTOP, and treating
	TCB_STARTUP and TCB_IGNORE_ONE_SIGSTOP as two slightly different things.

	* defs.h: Add a new flag bit, TCB_IGNORE_ONE_SIGSTOP.
	* process.c (internal_fork): Set TCB_IGNORE_ONE_SIGSTOP on a newly added child.
	* strace.c (startup_attach): Set TCB_IGNORE_ONE_SIGSTOP after attach.
	Fix a case when "strace -p PID" found PID dead but sone other of its threads
	still alive.
	(startup_child): Set TCB_IGNORE_ONE_SIGSTOP after attach, _if needed_.
	This fixes a bogus case where we can ignore a _real_ SIGSTOP on NOMMU.
	(detach): Perform anti-SIGSTOP dance only if TCB_IGNORE_ONE_SIGSTOP is set,
	not if TCB_STARTUP is set.
	(trace): Set TCB_IGNORE_ONE_SIGSTOP after attach.
	Clear TCB_STARTUP and initialize tracee on the very first tracee stop.
	Clear TCB_IGNORE_ONE_SIGSTOP when SIGSTOP is seen.

	Get rid of TCB_ATTACH_DONE.
	* defs.h: Remove TCB_ATTACH_DONE constant.
	* strace.c (startup_attach): Use TCB_STARTUP instead of TCB_ATTACH_DONE
	to distinquish attached from not-yet-attached threads.

	Set TCB_STARTUP only _after_ we attached.
	This fixes logic in detach() which thinks that TCB_STARTUP
	means that we are already attached, but did not see SIGSTOP yet.
	This also allows to get rid of TCB_ATTACH_DONE flag.

	* process.c (internal_fork): Set TCB_STARTUP after attach.
	* strace.c (startup_attach): Likewise.
	(startup_child): Likewise.
	(alloc_tcb): Do not set TCB_STARTUP on tcb allocation - we are
	not attached yet.
	(trace): Set TCB_STARTUP when we detech an auto-attached child.

2011-09-02  Denys Vlasenko  <dvlasenk@redhat.com>

	Simple optimizations in trace()
	* strace.c (trace): Calculate WSTOPSIG(status) once,
	unify code paths to ptrace(PTRACE_SYSCALL).

	Trivial fixes on error paths.
	* strace.c (startup_attach): Emit message on fork() failure.
	(startup_child): Remove non-informative comment.
	* util.c (ptrace_restart): use perror_msg() on error instead of fprintf().

2011-09-01  Denys Vlasenko  <dvlasenk@redhat.com>

	Fix compile failure introduced by last commit.
	* desc.c (decode_select): Fix double definition of nfds.

	Roll back "die on malloc failure" behaviour a bit.
	After recent change, select(2^31-1, NULL, NULL, NULL)
	would make strace exit. This change caps fdsize so that
	it is always in [0, 1025*1024], IOW: we will try to allocate at most
	1 megabyte, which in practice will almost always work,
	unlike malloc(2Gig).

	* desc.c (decode_select): Cap fdsize to 1024*1024.
	* pathtrace.c (pathtrace_match): Cap fdsize to 1024*1024.
	* file.c (sys_getdents): Cap len to 1024*1024.
	(sys_getdents64): Cap len to 1024*1024.
	* util.c (dumpiov): Refuse to process iov with more than 1024*1024
	elements. Don't die on malloc failure.
	(dumpstr): Don't die on malloc failure.

	Add stpcpy to autoconf machinery.
	* configure.ac: Add stpcpy to AC_CHECK_FUNCS.
	* defs.h: Frame stpcpy with "if !defined HAVE_STPCPY".
	* util.c: Likewise.

	Simplify sprinttv()
	* time.c (sprinttv): Trivial simplifications.

	* desc.c (decode_select): Set tcp->auxstr as late as possible.

	Reformat setuid-ing code in startup_child()
	New code does the same as old one, but is more readable (I hope).

	* strace.c (startup_child): Reformat setuid-ing code.

	Minor tweaks in startup_child(). Logic isn't changed (but code is)
	* strace.c (startup_attach): Tweak comment.
	(startup_child): Move common code out of ifdef.
	Indent nested ifdefs. Tweak comments. Remove two
	unnecessary calls to getpid().

	Use tprints with literal strings, it may be faster than tprintf.
	* bjm.c: Replace tprintf("str") with tprints("str").
	* block.c: Likewise.
	* desc.c: Likewise.
	* file.c: Likewise.
	* io.c: Likewise.
	* ipc.c: Likewise.
	* mem.c: Likewise.
	* net.c: Likewise.
	* proc.c: Likewise.
	* process.c: Likewise.
	* quota.c: Likewise.
	* resource.c: Likewise.
	* scsi.c: Likewise.
	* signal.c: Likewise.
	* sock.c: Likewise.
	* strace.c: Likewise.
	* stream.c: Likewise.
	* syscall.c: Likewise.
	* system.c: Likewise.
	* term.c: Likewise.
	* time.c: Likewise.
	* util.c: Likewise.

	Fix "format not a string literal" warning caused by tprintf(str)
	* defs.h: Declare tprints().
	* strace.c: Define tprints().
	(tabto): Use tprints(str), since tprintf(str) was throwing a warning.
	* desc.c: Use tprints(str) instead of tprintf("%s", str).
	* file.c: Likewise.
	* io.c: Likewise.
	* net.c: Likewise.
	* process.c: Likewise.
	* signal.c: Likewise.
	* syscall.c: Likewise.
	* util.c: Likewise.

2011-08-31  Denys Vlasenko  <dvlasenk@redhat.com>

	Add README-linux-ptrace file.
	I tried to push this doc to Michael Kerrisk <mtk.manpages@gmail.com>,
	but got no reply. To avoid losing the document, let it live
	in strace tree for now.

	Make out-of-memory handling more uniform.
	This fixes one real bug in dumpstr().

	* defs.h: Declare die_out_of_memory().
	* strace.c (die_out_of_memory): New function.
	(strace_popen): If allocation fails, call die_out_of_memory().
	(main): Likewise.
	(expand_tcbtab): Likewise.
	(rebuild_pollv): Likewise.
	* count.c (count_syscall): Likewise.
	(call_summary_pers): Likewise.
	* desc.c (decode_select): Likewise.
	* file.c (sys_getdents): Likewise.
	(sys_getdents64): Likewise.
	(sys_getdirentries): Likewise.
	* pathtrace.c (pathtrace_match): Likewise.
	* syscall.c (qualify): Likewise.
	* util.c (printstr): Likewise.
	(dumpiov): Likewise.
	(dumpstr): Likewise.
	(fixvfork): Likewise.
	* mem.c (sys_mincore): Don't check free() parameter for NULL.

	Optimization: eliminate all remaining usages of strcat()
	After this change, we don't use strcat() anywhere.

	* defs.h: Change sprinttv() return type to char *.
	* time.c (sprinttv): Return pointer past last stored char.
	* desc.c (decode_select): Change printing logic in order to eliminate
	usage of strcat() - use stpcpy(), *outptr++ = ch, sprintf() instead.
	Also reduce usage of strlen().
	* stream.c (decode_poll): Likewise.

	Optimize string_quote() for speed.
	* util.c (string_quote): Speed up check for terminating NUL.
	Replace strintf() with open-coded binary to hex/oct conversions -
	we potentially do them for every single byte, need to be fast.

	Optimization: eliminate some usages of strcat()
	* defs.h: Declare stpcpy().
	* util.c: Define stpcpy().
	* file.c: Remove static str_append().
	(sprint_open_modes): Use stpcpy() instead of str_append().
	(sprintflags): Use stpcpy() instead of strcat().
	(printpathn): Eliminate usage of strcat().
	(printstr): Eliminate usage of strcat().

2011-08-30  Denys Vlasenko  <dvlasenk@redhat.com>

	Small optimization on AVR32.
	* syscall.c (syscall_enter): Optimize tcp->u_arg[i] setting
	from regs.FOO for AVR32.

	On X86_64 and I386, use PTRACE_GETREGS to fetch all registers.
	Before this change, registers were read with PTRACE_PEEKUSER
	ptrace operation, one per register. This is slower than
	fetching them all in one ptrace operation.

	* defs.h: include asm/ptrace.h on X86_64 and I386.
	* syscall.c: New static variables i386_regs and x86_64_regs.
	Remove static eax/rax variables.
	(get_scno): Fetch all registers with single PTRACE_GETREGS operation.
	(get_syscall_result): Likewise.
	(syscall_fixup_on_sysenter): Use PTRACE_GETREGS results in i386/x86_64_regs.
	(syscall_enter): Set tcp->u_arg[i] from PTRACE_GETREGS results.
	(get_error): Set tcp->u_rval, tcp->u_error from PTRACE_GETREGS results.

2011-08-30  Dmitry V. Levin  <ldv@altlinux.org>

	Do not include <limits.h>
	* strace.c: Do not include <limits.h> explicitly, it is already included
	implicitly by <sys/param.h>.

	Include <sys/param.h> to get PATH_MAX definition.
	* pathtrace.c: Include <sys/param.h> instead of <limits.h> to get
	PATH_MAX definition.

	Reported-by: Steve Bennett <steveb@workware.net.au>

2011-08-26  Denys Vlasenko  <dvlasenk@redhat.com>

	Indent a large set of nested ifdefs/endifs. No code changes.
	* defs.h: Indent a large set of nested ifdefs/endifs

	Rename syscall_fixup to syscall_fixup_on_sysenter.
	* defs.h: Tweak comment.
	* syscall.c: Rename syscall_fixup to syscall_fixup_on_sysenter.
	(trace_syscall_entering): Use new finction name.

	Make syscall result reading more consistent among different arches.
	* syscall.c: Eliminate static flags variable for POWERPC.
	(syscall_fixup): Don't fetch syscall results. Affected arches:
	POWERPC, BFIN, HPPA.
	(syscall_fixup_on_sysexit): Move syscall results fetching code
	for this function to get_syscall_result. Affected arches:
	S390X, POWERPC, BFIN, M68K, HPPA, CRIS, MICROBLAZE.
	(get_syscall_result): Add syscall results fetching.

2011-08-25  Denys Vlasenko  <dvlasenk@redhat.com>

	Simplify syscall_fixup[_on_sysexit]
	* syscall.c (syscall_fixup): Remove checks for entering(tcp).
	Remove code which executes if exiting(tcp).
	(syscall_fixup_on_sysexit): Remove code which executes
	if entering(tcp). Remove checks for exiting(tcp).

	Split syscall_fixup into enter/exit pair of functions.
	* syscall.c: Create syscall_fixup_on_sysexit() which is a copy of
	syscall_fixup().
	(trace_syscall_exiting): Call syscall_fixup_on_sysexit() instead of
	syscall_fixup().

	Remove stray commas in struct initializers. No code changes.
	* process.c: Remove stray commas in struct initializers.

2011-08-24  Denys Vlasenko  <dvlasenk@redhat.com>

	Optimize tabto()
	tabto is used in many lines of strace output.
	On glibc, tprintf("%*s", col - curcol, "") is noticeably slow
	compared to tprintf("                 "). Use the latter.
	Observed ~15% reduction of time spent in userspace.

	* defs.h: Drop extern declaration of acolumn. Make tabto()
	take no parameters.
	* process.c (sys_exit): Call tabto() with no parameters.
	* syscall.c (trace_syscall_exiting): Call tabto() with no parameters.
	* strace.c: Make acolumn static, add static char *acolumn_spaces.
	(main): Allocate acolumn_spaces as a string of spaces.
	(printleader): Call tabto() with no parameters.
	(tabto): Use simpler method to print lots of spaces.

	* syscall.c (sys_indir): Use %ld for printing long, not %u.

	Opotimize "scno >= 0 && scno < nsyscalls" check.
	gcc can't figure out on its own that this check can be done with
	single compare, and does two compares. We can help it by casting
	scno to unsigned long: ((unsigned long)(scno) < nsyscalls)

	* defs.h: New macro SCNO_IN_RANGE(long_var).
	* count.c (count_syscall): Use SCNO_IN_RANGE() instead of open-coded check.
	* syscall.c (getrval2): Use SCNO_IN_RANGE() instead of open-coded check.
	This fixes a bug: missing check for scno < 0 and scno > nsyscalls
	instead of scno >= nsyscalls.
	(get_scno): Use SCNO_IN_RANGE() instead of open-coded check.
	This fixes a bug: scno > nsyscalls instead of scno >= nsyscalls.
	(known_scno): Use SCNO_IN_RANGE() instead of open-coded check.
	(internal_syscall): Likewise.
	(syscall_enter): Likewise.
	(trace_syscall_entering): Likewise.
	(get_error): Likewise.
	(trace_syscall_exiting): Likewise.

	Remove scno_good logic in syscall exit.
	* syscall.c (trace_syscall_exiting): Remove scno_good logic,
	it can't trigger in syscall exit.

	Remove redundant assignments.
	* syscall.c (get_error): Remove redundant "u_error = 0" and redundant
	and unclear comments.

	Group int-sized fields together in struct tcb.
	* defs.h: Group int-sized fields together in struct tcb.

	Reorder functions in syscall.c. No code changes.
	Old order (basically "in no particular order"):
	    dumpio
	    decode_subcall
	    internal_syscall
	    get_scno
	    get_syscall_result
	    known_scno
	    syscall_fixup
	    is_negated_errno
	    get_error
	    syscall_enter
	    trace_syscall_entering
	    trace_syscall_exiting
	    trace_syscall
	    printargs
	    getrval2
	    sys_indir
	    is_restart_error

	New order:
	various utility functions:
	    decode_subcall
	    printargs
	    getrval2
	    sys_indir
	    is_restart_error
	syscall enter handling functions:
	    get_scno
	    known_scno
	    syscall_fixup (also used in syscall exit code)
	    internal_syscall (also used in syscall exit code)
	    syscall_enter
	    trace_syscall_entering
	syscall exit handling functions:
	    get_syscall_result
	    is_negated_errno
	    get_error
	    dumpio
	    trace_syscall_exiting
	main syscall enter/exit function:
	    trace_syscall

	* syscall.c: Reorder functions so that related ones are closer
	in the source.

	Rename some functions, delete unused one. No code changes.
	* defs.h: Rename get_scno_on_sysenter() to get_scno();
	delete force_result() declaration.
	* strace.c (proc_open): Rename get_scno_on_sysenter() to get_scno().
	* syscall.c: Rename get_scno_on_sysenter() to get_scno().
	Rename get_scno_on_sysexit() to get_syscall_result().
	Delete unused force_result().

	Unify per-architecture post-execve SIGTRAP check.
	Move post-execve SIGTRAP check from get_scno_on_sysenter
	(multitude of places on many architectures) to a single location
	in trace_syscall_entering. This loosens the logic for some arches,
	since many of them had additional checks such as scno == 0.
	However, on non-ancient Linux kernels we should never have post-execve
	SIGTRAP in the first place, by virtue of using PTRACE_O_TRACEEXEC.

	* syscall.c (get_scno_on_sysenter): Remove tcp->flags & TCB_WAITEXECVE checks.
	(trace_syscall_entering): Do tcp->flags & TCB_WAITEXECVE check here.
	(get_scno_on_sysexit): Tweak comment.
	(syscall_fixup): Likewise.
	(trace_syscall_exiting): Likewise.

	Speed up x86 by avoiding EAX read on syscall entry.
	on x86, EAX read on syscall entry is not necessary if we know
	that post-execve SIGTRAP is disabled by PTRACE_O_TRACEEXEC ptrace option.
	This patch (a) moves EAX retrieval from syscall_fixup
	to get_scno_on_sysexit, and (b) perform EAX retrieval in syscall_fixup
	only if we are in syscall entry and PTRACE_O_TRACEEXEC option is not on.

	* syscall.c (get_scno_on_sysexit): On I386 and X86_64, read eax/rax
	which contain syscall return value.
	(syscall_fixup): On I386 and X86_64, read eax/rax only on syscall enter
	and only if PTRACE_O_TRACEEXEC is not in effect.

	Do not read syscall no in get_scno_on_sysexit.
	* syscall.c (get_scno_on_sysexit): Remove scno retrieval code, since
	we don't save it anyway. This is the first real logic change
	which should make strace faster: for example, on x64 ORIG_EAX
	is no longer read in each syscall exit.

	Simplify get_scno_on_sysenter/sysexit.
	* syscall.c (get_scno_on_sysenter): Remove "if (exiting(tcp))" code,
	make "if (entering(tcp))" code unconditional.
	(get_scno_on_sysexit): Remove "if (entering(tcp))" code,
	make "if (exiting(tcp))" code unconditional.

	get_scno is an unholy mess, make it less horrible.
	Currently, get_scno does *much* more than "get syscall no".
	It checks for post-execve SIGTRAP. It checks for changes
	in personality. It retrieves params on entry and registers on exit.
	Worse still, it is different in different architectures: for example,
	for AVR32 regs are fetched in get_scno(), while for e.g. I386
	it is done in syscall_enter().

	Another problem is that get_scno() is called on both syscall entry and
	syscall exit, which is stupid: we don't need to know scno on syscall
	exit, it is already known from last syscall entry and stored in
	tcp->scno! In essence, get_scno() does two completely different things
	on syscall entry and on exit, they are just mixed into one bottle, like
	shampoo and conditioner.

	The following patches will try to improve this situation.

	This change duplicates get_scno into identical get_scno_on_sysenter,
	get_scno_on_sysexit functions. Call them in syscall enter and syscall
	exit, correspondingly.

	* defs.h: Rename get_scno to get_scno_on_sysenter; declare it only
	if USE_PROCFS.
	* strace.c (proc_open): Call get_scno_on_sysenter instead of get_scno.
	* syscall.c (get_scno): Split into two (so far identical) functions
	get_scno_on_sysenter and get_scno_on_sysexit.
	(trace_syscall_entering): Call get_scno_on_sysenter instead of get_scno.
	(trace_syscall_exiting): Call get_scno_on_sysexit instead of get_scno.

2011-08-23  Dmitry V. Levin  <ldv@altlinux.org>

	Reduce code redundancy in syscall_enter()
	* syscall.c [LINUX] (syscall_enter): Move tcp->u_nargs initialization
	from arch-specific ifdefs to common code.  Always cache tcp->u_nargs in
	a local variable and use it in for() loops.
	[IA64, AVR32] Rewrite tcp->u_arg[] initialization using a loop.

2011-08-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Define MAX_ARGS to 6 for all Linux arches.
	* defs.h: Define MAX_ARGS to 6 for all Linux arches.
	* linux/ia64/syscallent.h: Change all 8-argument printargs
	to MA (MAX_ARGS).
	linux/mips/syscallent.h: Change all two 7-argument printargs
	to MA (MAX_ARGS).

	Fix argument printing in sys_mmap64.
	* mem.c (sys_mmap64): Fix a bug where we used tcp->u_args[i]
	instead of argument values copied from memory.

	Cache tcp->u_nargs in a local variable for for() loops.
	Loops of the form "for (i = 0; i < tcp->u_nargs; i++) ..."
	need to fetch tcp->u_nargs from memory on every iteration
	if "..." part has a function call (gcc doesn't know that
	tcp->u_nargs won't change). This can be sped up
	by putting tcp->u_nargs in a local variable, which might
	go into a CPU register.

	* syscall.c (decode_subcall): Cache tcp->u_nargs in a local variable
	as for() loop limit value.
	(syscall_enter): Likewise.

	Drop checks for sysent[i].nargs == -1.
	* defs.h: Declare nsyscalls, nerrnos, nioctlents, nsignals as unsigned.
	* syscall.c: Define nsyscalls, nerrnos, nioctlents, nsignals as unsigned.
	(decode_subcall): Drop checks for sysent[i].nargs == -1.
	(syscall_enter): Likewise.

	Stop using nargs == -1 in syscallent tables.
	Usage -1 as argument count in syscallent tables
	necessitates the check for it, a-la:
	if (sysent[tcp->scno].nargs != -1)
	    tcp->u_nargs = sysent[tcp->scno].nargs;
	else
	    tcp->u_nargs = MAX_ARGS;
	which is stupid: we waste cycles checking something which
	is constant and known at compile time.

	* defs.h: Make struct sysent::nargs unsigned.
	* freebsd/i386/syscallent.h: Replace nargs of -1 with MA.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* svr4/syscallent.h: Likewise.
	* freebsd/syscalls.pl: Likewise in generator script.
	* syscallent.sh: Likewise in generator script.
	* syscall.c: Add define MA MAX_ARGS / undef MA around includes
	of syscallent[N].h.

	Move trace_syscall_exiting below trace_syscall_entering. No code changes.
	Syscall enter happens before syscall exit. Having functions
	in opposite order in the source is confusing.

	* syscall.c: Move trace_syscall_exiting below trace_syscall_entering.

	Fix -z display.
	Before this patch, the following:
	    open("qwerty", O_RDONLY)    = -1 ENOENT
	    write(2, "wc: qwerty: No such file or dire"..., 38) = 38
	was shown totally wrongly with -z:
	    open("qwerty", O_RDONLY)    = 38
	(yes, that's right, write syscall is lost!)
	Now it is shown "less wrongly" as:
	    open("qwerty", O_RDONLY <unfinished ...>
	    write(2, "wc: qwerty: No such file or dire"..., 38) = 38

	* syscall.c (trace_syscall_exiting): Use common TCB_INSYSCALL clearing
	via "goto ret". This fixes totally broken display of -z, but even now
	it is not working as intended. Add a comment about that.
	(trace_syscall_entering): Use common TCB_INSYSCALL setting
	via "goto ret".

	Straighten up confused comments/messages about post-execve SIGTRAP handling
	* defs.h: Explain TCB_INSYSCALL and TCB_WAITEXECVE bits in detail.
	* strace.c (choose_pfd): Use entering/exiting macros instead of direct check
	for TCB_INSYSCALL.
	* syscall.c (get_scno): Use entering/exiting macros instead of direct check
	for TCB_INSYSCALL. Fix comments about post-execve SIGTRAP.
	(syscall_fixup): Use entering/exiting instead of direct check
	for TCB_INSYSCALL. Add a comment what "not a syscall entry" message
	usually means. Change wrong "stray syscall exit" messages into
	"not a syscall entry" ones.

	count_syscall() always returns 0, optimize it.
	* defs.h (count_syscall): Change return type from int to void.
	* count.c (count_syscall): Change return type from int to void.
	* syscall.c (trace_syscall_exiting): Change code around call
	to count_syscall accordingly.

	Optimize out dummy PC printing on signal delivery.
	* strace.c (trace): Optimize out dummy PC printing on signal delivery.
	While at it, tweak comments.

	Conditionally optimize out unused code.
	* syscall.c (internal_syscall): Call internal_exec only if
	SUNOS4 || (LINUX && TCB_WAITEXECVE).
	* process.c (internal_exec): Define this function only if
	SUNOS4 || (LINUX && TCB_WAITEXECVE).
	(printwaitn): Don't check wordsize if SUPPORTED_PERSONALITIES == 1.
	* signal.c (sys_kill): Likewise.
	* syscall.c (is_negated_errno): Likewise.
	(trace_syscall_exiting): Fold a tprintf into tprintfs which follow it.

	Cosmetic improvement in ifdefs. No code changes.
	* strace.c (proc_open): Change ifdefs so that braces are properly paired.

	Exclude tcp->pfd from non-procfs systems.
	* defs.h: Make struct tcb::pfd fields conditional on USE_PROCFS.
	* strace.c (alloc_tcb): Use tcp->pfd only if USE_PROCFS.
	(droptcb): Likewise.

	Small optimizations related to memory allocation.
	* strace (expand_tcbtab): Shorten "out of memory" message.
	(rebuild_pollv): Remove unnecessary NULL check before free().
	* util.c (dumpstr): Add a comment about likely bug.

	Improve code readability by avoiding assignments inside if()
	* desc.c (decode_select): Move assignment out of if() condition.
	* file.c (sprinttime): Likewise.
	(sys_getdirentries): Likewise.
	* io.c (sys_ioctl): Likewise.
	* strace.c (test_ptrace_setoptions_followfork): Likewise.
	(main): Likewise.
	(proc_open): Likewise.
	(detach): Likewise.
	(proc_poll): Likewise.
	(trace): Likewise.
	* syscall.c (qualify): Likewise.
	(sys_indir): Likewise.
	* test/procpollable.c (main): Likewise.
	* test/sfd.c (main): Likewise.
	* time.c (printtv_bitness): Likewise.
	(sprinttv): Likewise.
	(print_timespec): Likewise.
	(void sprint_timespec): Likewise.
	(printitv_bitness): Likewise.
	* util.c (dumpstr): Likewise.
	(umovestr): Likewise.
	(fixvfork): Likewise.

	Convert ioctl_next_match() to new-style C function definition.
	* ioctl.c (ioctl_next_match): Convert to new-style C function definition.

	Small optimization in signal and ioctl tables.
	Trivial shuffling of data tables puts them all in one file,
	allowing gcc to see their sizes and eliminate variables
	which store these sizes.

	Surprisingly, in C mode gcc does not optimize out static const int
	variables. Help it by using enums instead.

	* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
	signalent{0,1,2}, nsignals{0,1,2}.
	* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
	* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
	* syscall.c: Move above definitions to this file. Make them static const
	or enums if suitable.

	Don't return int from set_personality(), no one checks it.
	* defs.h (set_personality): Change return type to void.
	* syscall.c (set_personality): Change return type to void.

	Remove unused declaration.
	* defs.h: Remove unused declaration of handle_new_child().

	Use natural-sized integer field for tcb::flags.
	* defs: Change struct tcb::flags type from short to int.
	This results in smaller code at least on x86.

	Make needlessly static data local.
	* syscall.c (get_scno): For POWERPC64 and X86-64, variable currpers
	is declared static. But its old data is never used. Convert it
	to ordinary local variable.

	Optimize get_scno function.
	* syscall.c (get_scno): Make gpr_offset[] array static const.

	Optimize iocb_cmd_lookup.
	* desc.c (iocb_cmd_lookup): Make command table constant.
	Reduce size of static char buffer.

	Correct sys_sendfile[64] type and nargs.
	* freebsd/i386/syscallent.h: Correct sys_sendfile nargs 7->8
	* linux/mips/syscallent.h: Correct sys_sendfile64 nargs 5->4
	* linux/sh/syscallent.h: Correct sys_sendfile64 nargs 5->4
	* linux/sh64/syscallent.h: Correct sys_sendfile64 nargs 5->4
	* linux/m68k/syscallent.h: Correct sys_sendfile64 type TF->TD|TN
	* linux/microblaze/syscallent.h: Correct sys_sendfile64 type TF->TD|TN
	* linux/tile/syscallent.h: Correct sys_sendfile and sys_sendfile64 type TD->TD|TN

	Make addflags return void.
	* defs.h (addflags): Change return type from int to void.
	* util.c (addflags): Change return type from int to void.

	Set saner MAX_ARGS (6 or 8) for X86_64 and I386.
	I noticed that tcp->u_args[MAX_ARGS] array is way larger than
	I'd expect: for all arches except HPPA it has 32 (!) elements.

	I looked at the code and so far I spotted only one abuser of
	this fact: sys_sigreturn. On several arches, it saves sigset_t
	into tcp->u_args[1...N] on entry and prints it on exit, a-la

	memcpy(&tcp->u_arg[1], &sc.oldmask[0], sizeof(sigset_t))

	The problem here is that in glibc sigset_t is insanely large:
	128 bytes, and using sizeof(sigset_t) in memcpy will overrun
	&tcp->u_args[1] even with MAX_ARGS == 32:
	On 32 bits, sizeof(tcp->u_args) == 32*4 == 128 bytes!
	We may already have a bug there!

	This commit changes the code to save NSIG / 8 bytes only.
	NSIG can't ever be > 256, and in practice is <= 129,
	thus NSIG / 8 is <= 16 bytes == 4 32-bit words,
	and even MAX_ARGS == 5 should be enough for saving signal masks.

	* defs.h: Reduce MAX_ARGS for X86_64 and I386 from 32 to 8
	for FreeBSD and to 6 for everyone else. Add comment about current
	state of needed MAX_ARGS.
	* signal.c: Add comment about size of sigset_t.
	(sprintsigmask): Reduce static string buffer from 8k to 2k.
	(sys_sigreturn): Fix sigset saving to save only NSIG / 8 bytes,
	not sizeof(sigset_t) bytes.
	* linux/mips/syscallent.h: Reduce nargs of printargs-type syscall to 7.
	* linux/arm/syscallent.h: Reduce nargs of printargs-type syscall to 6.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.

	Optimize sys_old_mmap.
	* mem.c (sys_old_mmap): For Ia64 and 32-bit personality of x86-64,
	copy narrow parameters from userspace by single umove, not by six
	separate ones; then assign them to long u_arg[i]. For SH[64],
	avoid copying of tcp->u_arg.
	(sys_mmap): Add FIXME comment - SH64 and i386 seem to be handled
	differently for no apparent reason.
	* test/mmap_offset_decode.c: New test program, illustrates FIXME.

	Untangle ifdef forest in sys_mmap64. No code changes.
	After careful analysis, it looks like !LINUX and ALPHA
	pass all seven parameters in registers; and in all other cases
	parameters are on stack (pointed to by tcp->u_arg[0]).
	In light of this, reorganize ifdefs, making them simpler,
	without changing any logic.
	After this, it's apparent we use tcp->u_arg[4,5,6] and possibly
	[7] without checking that it's valid to do so.
	So far, just add a comment about this.

	* mem.c (sys_mmap64): Rewrite ifdefs in a much simpler way.
	Add comments about apparent bugs.

	Style and comment fixes, no code changes.
	* mem.c: Indent includes to show nesting better.
	  (addtileflags): Fix style of this function definition;
	  correct wrong endif comment, add another endif comment.

	Use simpler rounding up to next multiple of 2.
	* util.c (printllval): simpler rounding up to next multiple of 2.

	Cosmetic fixes, no code changes.
	* defs.h: Add/reformat comments.
	* signal.c: Remove wrong comment. Add warning directive
	when we detect that NSIG is undefined. Add comment about
	NSIG on ARM. Fix typo in comment.
	(signame): Reformat code a bit without changes to logic.
	Shorten static buffer.
	(sys_rt_sigprocmask): Remove stray empty line.
	* syscall.c: Add warning directive when we detect that
	NSIG is undefined. Add comment about NSIG on ARM.

2011-08-23  Dmitry V. Levin  <ldv@altlinux.org>

	Fix PTRACE_SETOPTIONS tests.
	* strace.c [LINUX] (kill_save_errno): New function.
	(test_ptrace_setoptions_followfork): Change return type to void.
	Fix and harden error handling.  Use kill_save_errno() to avoid errno
	clobbering.  Treat EIO from ptrace() the same way as EINVAL.
	(test_ptrace_setoptions_for_all): Use kill_save_errno() to avoid errno
	clobbering.  Treat EIO from ptrace() the same way as EINVAL.
	(main): Update use of test_ptrace_setoptions_followfork().

	Fix compilation on linux 2.4.x.
	* configure.ac: Check for BLKGETSIZE64.
	* block.c (block_ioctl): Check for HAVE_BLKGETSIZE64.

2011-08-17  Denys Vlasenko  <dvlasenk@redhat.com>

	Remove tcp->parent and TCB_CLONE_THREAD.
	tcp->parent is used for only two things:
	(1) to send signal on detach via tgkill (need to know tgid).
	Solution: use tkill, it needs only tid.
	(2) to optimize out ptrace options setting for new tracees.
	Not a big deal if we drop this optimization: "set options" op is fast,
	doing it just one extra time once per each tracee is hardly measurable.

	TCB_CLONE_THREAD is a misnomer. It used only to flag sibling we attached to
	in startup_attach. This is used to prevent infinite recursive rescanning
	of /proc/PID/task.
	Despite the name, there is no guarantee it is set only on non-leader:
	if one would run "strace -f -p THREAD_ID" and THREAD_ID is *not*
	a thread leader, strace will happily attach to it and all siblings
	and will think that THREAD_ID is the leader! Which is a bug, but
	since we no longer detach when we think tracee is going to die,
	this bug no longer matters, because we do not use the knowledge
	about thread group leaders for anything. (We used it to delay
	leader's exit).

	IOW: after this patch strace has no need to know about threads, parents
	and children, and so on. Therefore it does not track that information.
	It treats all tracees as independent entities. Overall,
	this simplifies code a lot.

	* defs.h: Add TCB_ATTACH_DONE flag, remove TCB_CLONE_THREAD flag
	and struct tcb::parent field.
	* process.c (internal_fork): Don't set tcpchild->parent.
	* strace.c (startup_attach): Use TCB_ATTACH_DONE flag instead of
	TCB_CLONE_THREAD to avoid attach attempts on already-attached threads.
	Unlike TCB_CLONE_THREAD, TCB_ATTACH_DONE bit is used only temporarily,
	and only in this function. We clear it on every tcb before we return.
	(detach): Use tkill instead of tgkill.
	(trace): Set ptrace options on new tracees unconditionally,
	not only when tcp->parent == NULL.

	Remove TCB_SUSPENDED constant and related code.
	Since we no longer suspend waitpid'ing tracees, we have only one case when
	we suspend tracee: when we pick up a new tracee created by clone/fork/vfork.

	Background: on some other OSes, attach to child is done this way:
	get fork's result (pid), loop ptrace(PTRACE_ATTACH) until you hook up
	new process/thread. This is ugly and not safe, but what matters for us
	is that it doesn't require suspending. Suspending is required
	on Linux only, because on Linux attach to child is done differently.

	On Linux, we use two methods of catching new tracee:
	adding CLONE_THREAD bit to syscall (if needed, we change
	[v]fork into clone before that), or using ptrace options.
	In both cases, it may be so that new tracee appears before one which
	created it returns from syscall. In this case, current code
	suspends new tracee until its creator returns. Only then
	strace can determine who is its parent (it needs child's pid for this,
	which is visible in parent's [v]fork/clone result).
	This is inherently racy. For example, what if SIGKILL kills
	creator after it succeeded creating child, but before it returns?
	Looks like we will have child suspended forever.

	But after previous commit, we DO NOT NEED parent<->child link for anything.
	Therefore we do not need suspending too. Bingo!

	This patch removes suspending code. Now new tracees will be continued
	right away. Next patch will remove tcp->parent member.

	* defs.h: Remove TCB_SUSPENDED constant
	* process.c (handle_new_child): Delete this function.
	  (internal_fork): Do not call handle_new_child on syscall exit.
	* strace.c (handle_ptrace_event): Delete this function.
	  (trace): Do not suspend new child; remove all handling
	  of now impossible TCB_SUSPENDED condition.

	Do not detach when we think tracee is going to die.
	Current code plays some ungodly tricks, trying to not detach
	thread group leader until all threads exit.

	Also, it detaches from a tracee when signal delivery is detected
	which will cause tracee to exit.
	This operation is racy (not to mention the determination
	whether signal is set to SIG_DFL is a horrible hack):
	after we determined that this signal is indeed fatal
	but before we detach and let process die,
	*other thread* may set a handler to this signal, and
	we will leak the process, falsely displaying it as killed!

	I need to look in the past to figure out why we even do it.
	First guess is that it's a workaround for old kernel bugs:
	kernel used to deliver exit notifications to the tracer,
	not to real parent. These workarounds are ancient
	(internal_exit is from 1995).

	The patch deletes the hacks. We no longer need tcp->nclone_threads,
	TCB_EXITING and TCB_GROUP_EXITING. We also lose a few rather
	ugly functions.

	I also added a new message: "+++ exited with EXITCODE +++"
	which shows exact moment strace got exit notification.
	It is analogous to existing "+++ killed by SIG +++" message.

	* defs.h: Delete struct tcb::nclone_threads field,
	  TCB_EXITING and TCB_GROUP_EXITING constants,
	  declarations of sigishandled() and internal_exit().
	* process.c (internal_exit): Delete this function.
	  (handle_new_child): Don't ++tcp->nclone_threads.
	* signal.c (parse_sigset_t): Delete this function.
	  (sigishandled): Delete this function.
	* strace.c (startup_attach): Don't tcbtab[tcbi]->nclone_threads++.
	  (droptcb): Don't delay dropping if tcp->nclone_threads > 0,
	  don't drop parent if its nclone_threads reached 0:
	  just drop (only) this tcb unconditionally.
	  (detach): don't drop parent.
	  (handle_group_exit): Delete this function.
	  (handle_ptrace_event): Instead of handle_group_exit, just drop tcb;
	  do not panic if we see WIFEXITED from an attached pid;
	  print "+++ exited with EXITCODE +++" for every WIFEXITED pid.
	* syscall.c (internal_syscall):	Do not treat sys_exit specially -
	  don't call internal_exit on it.

2011-08-16  Sergei Trofimovich  <slyfox@gentoo.org>

	Declare printrusage32() on Alpha.
	* defs.h [ALPHA] (printrusage32): New declaration.

2011-08-15  Denys Vlasenko  <dvlasenk@redhat.com>

	Slight optimization and cleanup in trace()
	* strace.c (trace): Do not recalculate "cflag ? &ru : NULL"
	again and again. Do not clear errno unnecessarily.
	Consistently check wait errors as pid < 0, not pid == -1.
	Indent ifdefs for better readability.
	Remove comments after endif if ifdef/endif block is really tiny.

	Fix compilation on 2.4.20 kernel based system.
	* block.c (block_ioctl): add ifdef/endif around BLKGETSIZE64 usage
	* strace.c (trace): add ifdef/endif around WIFCONTINUED usage

2011-07-19  Dmitry V. Levin  <ldv@altlinux.org>

	Check for additional PTRACE_* constants.
	* configure.ac (AC_CHECK_DECLS): Add PTRACE_O_TRACESYSGOOD,
	PTRACE_O_TRACEEXEC, PTRACE_O_TRACEEXIT, PTRACE_EVENT_EXEC,
	PTRACE_EVENT_VFORK_DONE and PTRACE_EVENT_EXIT.
	* defs.h [LINUX]: Define these PTRACE_* constants when they are not
	provided by <sys/ptrace.h>.

	Reported-by: Douglas Mencken <dougmencken@gmail.com>
	Reported-by: Steve Bennett <steveb@workware.net.au>

2011-07-19  Denys Vlasenko  <dvlasenk@redhat.com>

	Remove superfluous backslash-continuation in configure.ac.
	* configure.ac: remove superfluous backslash continuation
	in AC_CHECK_DECLS

2011-06-24  Denys Vlasenko  <dvlasenk@redhat.com>

	Make IOCTL_WSTOP more readable.
	* defs.h: Make IOCTL_WSTOP more readable

	Trivial cleanups.
	* strace.c (trace): Change ifdef LINUX to make a bit more sense,
	  remove wrong comment at its endif. Slightly optimize
	  "+++ killed by SIG +++" message for systems without WCOREDUMP macro.

	Remove redundant include <stdarg.h>
	* strace.c: Remove redundant include <stdarg.h>

	Clean up two old comments.
	* strace.c (startup_attach): Remove misplaced comment.
	  (trace) Remove incomplete part of a comment.

	Make a few variables static.
	* defs.h: Remove tcbtab declaration.
	* strace.c: Make run_uid, run_gid, outf, tcbtab, progname
	  global variables static

	Add debug output in initial attachment code.
	* strace.c (startup_attach): If -d, report pid and success/failure
	  of every attach attempt.

	Better debug logging of allocations and waitpit results.
	* strace.c (alloc_tcb): Print number of allocated tcb's if -d.
	  (droptcb): Likewise.
	  (handle_ptrace_event): Remove PTRACE_EVENT_EXEC debug message.
	  (trace): Improve logging of waitpid: show WIFxxx, exitcode/signal,
	  ptrace event name, WCOREDUMP - all on one line.

2011-06-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Optimize arrays of register indexes in syscall_enter.
	* syscall.c (syscall_enter) [BFIN]: Make register no array "static const".
	  [SH]: Make register no array "const", pre-multiply it by 4.
	  [SH64]: Make register no array "const".
	  [X86_64]: Make register no array "const", pre-multiply it by 8.

	Deindent syscall_enter by removing unnecessary braces. No code changes.
	syscall_enter has many long (>80 columns) lines.
	It is aggravated by the fact that it has a lot of {} blocks
	which are not necessary (the code is the same without them).
	This patch removes {}s and deindents affected lines.
	While at it, it indents ifdefs so that nesting is easier to track,
	and adds a few spaces in the expressions, such as
	"tcp->u_nargs*sizeof..." -> "tcp->u_nargs * sizeof...".
	There is no actual changes to the code here.

	* syscall.c (syscall_enter): Remove unnecessary {} blocks.

	Remove dead "ifndef CLONE_PTRACE" branch.
	process.c defines CLONE_PTRACE for Linux, so it can't be undefined.
	Therefore ifndef CLONE_PTRACE code is dead (since at least 2004).
	This patch removes it.

	* process.c (handle_new_child): Remove ifdef CLONE_PTRACE/endif (but not
	  the code inside) and entire ifndef CLONE_PTRACE/endif block.

	Add a comment about setbpt. No code changes.
	* defs.h: Add a comment about setbpt().

	Untangle a particularly badly obfuscated bit of code. No logic changes.
	* util.c (setbpt): Calculate new arg0 in more readable way.

	Remove TCB_FOLLOWFORK.
	TCB_FOLLOWFORK flag seems to be unnecessary, because we either follow
	all [v]forks/clones or don't follow any, therefore global variable
	followfork is an already existing indicator of what we want to do.
	This patch drops all setting/clearing of TCB_FOLLOWFORK bit,
	and replaces checks for this bit by checks of followfork value.
	In internal_fork, check is moved to in front of if(), since
	the check is needed on both "entering" and "exiting" branch.

	* defs.h: Remove TCB_FOLLOWFORK define.
	* process.c (internal_fork): Do not set/clear TCB_FOLLOWFORK,
	  test followfork instead of tcp->flags & TCB_FOLLOWFORK.
	  (handle_new_child): Likewise.
	* strace.c (startup_attach): Likewise.

2011-06-23  Dmitry V. Levin  <ldv@altlinux.org>

	* system.c (sys_capget, sys_capset): Fix pointer arithmetics.

2011-06-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Make initial tcb allocation more readable. No logic changes.
	* strace.c (main): Make initial tcb allocation more readable.

	Do not allocate tiny cap_user_header/data structures, place them on stack.
	This allows us to avoid having code to malloc them, and code to check
	for malloc failure. Resulting code decrease:
	   text	   data	    bss	    dec	    hex	filename
	  10175	      0	     16	  10191	   27cf	system.o.old
	   9797	      0	      0	   9797	   2645	system.o

	* system.c (sys_capget): Put cap_user_header_t and cap_user_data_t
	  on stack, rather than allocating them in heap. These structures
	  are very small (a few integer fields), stack is a better place
	  for them.
	  (sys_capset): Likewise.

	Use [p]error_msg[_and_die] where appropriate. No logic changes.
	Resulting size changes:
	   text    data     bss     dec     hex filename
	  17445      16    8572   26033    65b1 strace.o.old
	  16850      16    8572   25438    635e strace.o

	* strace.c: Replace fprintf[+cleanup]+exit with [p]error_msg_and_die,
	  fprintf("progname: ...") with [p]error_msg where appropriate.

2011-06-22  Denys Vlasenko  <dvlasenk@redhat.com>

	Whitespace cleanups. No code changes.
	* count.c: Place opening curly brace after if (),
	  not on the next line. Almost all strace code alredy
	  uses this style.
	* desc.c: Likewise.
	* file.c: Likewise.
	* net.c: Likewise.
	* pathtrace.c: Likewise.
	* process.c: Likewise.
	* quota.c: Likewise.
	* signal.c: Likewise.
	* strace.c: Likewise.
	* syscall.c: Likewise.
	* time.c: Likewise.

	Make strace_fopen abort on error.
	Error from strace_fopen in main results in call to exit(1).
	Error from strace_fopen in newoutf is propagated to newoutf
	callers: startup_attach (where it results in exit(1))
	and alloc_tcb (where error is ignored). In second case,
	the behavior doesn't seem to be right: it means with -ff
	on open error for new LOGFILE.PID the output will continue
	to go into *the same file as the previous process* - which
	would be confusing. Moreover, on droptcb outf may be closed
	and the output of other, still running process outputting
	to the same outf will be lost. I don't think this is sane.
	IOW: in all cases, error in strace_fopen should be fatal.

	* strace.c (strace_fopen): Abort on error instead of returning NULL.
	  (newoutf): Change return type to void.
	  (startup_attach): Remove error check on newoutf return value.
	  (main): Remove error check on strace_fopen return value.

	Make set_cloexec_flag abort on error.
	set_cloexec_flag() may fail only if we pass it a bad fd,
	such as -1 or non-opened one. If we do, we have a bug
	in the caller. It makes no sense to try to continue
	running when we detect such a blatant bug in our own code.

	* strace (set_cloexec_flag): Abort instead of returning error
	  indicator. Change function to return void.
	  (strace_fopen): Remove error check on set_cloexec_flag return value.
	  (proc_open): Likewise.
	  (proc_poll_open): Likewise.

	Make strace_popen abort on error.
	It makes no sense to postpone abort on strace_popen error
	unti it returns. Moreover, out-of-memory error was exiting
	without any message.
	While at it, use 0 as "none" for popen_pid, as optimization.

	* strace: Initialize popen_pid to 0 - this puts it in bss.
	  (trace): Reset popen_pid to 0 instead of -1.
	  (strace_popen): Never return NULL as error indicator,
	  abort with good error message instead.
	  (main): Remove NULL check of strace_popen result.

	Delete fork_tcb()
	Get rid of fork_tcb() function. It used to do what the comment
	above it says, but now it doesn't do much:
	it only sets tcp->flags |= TCB_FOLLOWFORK and maybe calls
	expand_tcbtab(). The second operation is not necessary, since
	alloc_tcp() will do it itself when needed.
	This patch deletes fork_tcb(), open-coding tcp->flags |= TCB_FOLLOWFORK
	where it was formerly called. It also makes nprocs, tcbtabsize and
	expand_tcbtab() static. (While at it, I nuked redundant
	extern char **environ declaration: strace.c had *two* of them...)

	* defs.h: Remove declarations of nprocs, tcbtabsize and
	  expand_tcbtab.
	* process.c (fork_tcb): Remove this function.
	  (internal_fork): Open-code fork_tcb.
	  (handle_new_child): Likewise.
	* strace.c: Remove redundant "extern char **environ". Declare
	  nprocs and tcbtabsize static.
	  (expand_tcbtab): Make it static.

	Simplify expand_tcbtab and alloc_tcb.
	Get rid of a few intermediate variables, simplifies a few expressions,
	and uses error_msg_and_die instead of more verbose
	fprintf+cleanup+exit sequence.
	In alloc_tcp, I use memset to clear entire new tcp.
	This not only saves a few bytes of code, but lowers the chances
	of future bugs where some data "leaks out" into new tcb's
	from old ones because we forgot to re-initialize it.

	* strace.c (expand_tcbtab): Simplify this function. No logic changes.
	  (alloc_tcb): Likewise.

2011-06-21  Denys Vlasenko  <dvlasenk@redhat.com>

	Trivial fixes.
	* process.c (internal_fork): Remove conditionals which make no difference
	  (we return 0 on both branches of these ifs).
	* util.c: Fix indentation of an ifdef.

2011-06-21  Dmitry V. Levin  <ldv@altlinux.org>

	Fix build when libaio-devel is not available.
	* desc.c: Do not compile code that uses struct iocb unless
	HAVE_LIBAIO_H is set.

	Reported-by: Denys Vlasenko <dvlasenk@redhat.com>

	tests: finish ptrace_setoptions_* merge.
	* tests/Makefile.am (TESTS): Merge ptrace_setoptions_*.
	* tests/ptrace_setoptions: Check for Linux kernel > 2.6.

2011-06-21  Denys Vlasenko  <dvlasenk@redhat.com>

	Remove write-only nchildren member from struct tcb.
	* defs.h: Remove nchildren member from struct tcb.
	* process.c (handle_new_child): Remove inc/decrements of tcp->nchildren.
	  (internal_fork): Likewise.
	* strace.c (startup_attach): Likewise.
	  (droptcb): Likewise.
	  (alloc_tcb): Remove initialization of tcp->nchildren.

	Fix tests/ptrace_setoptions_* to match last fix in ptrace options code.

	Remove write-only nzombies member from struct tcb.
	* defs.h: Remove nzombies member from struct tcb.
	* strace.c (droptcb): Remove "tcp->parent->nzombies++".
	  (alloc_tcb): Remove "tcp->nzombies = 0".

	Fix regression introduced by "Properly handle real SIGTRAPs" change.
	Commit 3454e4b463e6c22c7ea8c5461ef5a077f4650a54
	introduced a bug: sometimes, TRACECLONE/TRACE[V]FORK opts were not set.
	The check (tcp->parent == NULL) in old code was meant to check
	"if we are not a child created by auto-attach" - in this case,
	options need to be set on the child; otherwise they are inherited
	and do not need to be set.
	I misunderstood the check and if tcp->parent is not NULL, I was
	setting only ptrace_setoptions_for_all bits.
	This change fixes the problem. Since the fixed logic makes it
	unnecessary to keep two sets of options in separate variables,
	I merge them back into one variable, ptrace_setoptions.

	* defs.h: Merge ptrace_setoptions_followfork and ptrace_setoptions_for_all
	  into one variable, ptrace_setoptions.
	* strace.c: Likewise.
	  (test_ptrace_setoptions_followfork): Use ptrace_setoptions variable.
	  (test_ptrace_setoptions_for_all): Likewise.
	  (main): Likewise.
	* process.c (internal_fork): Likewise.
	  (internal_exec): Likewise.
	* strace.c (trace): Fix the bug where different options were set
	  depending on "tcp->parent == NULL" condition. Add a comment
	  which makes it more clear why this condition is checked.

2011-06-18  Denys Vlasenko  <dvlasenk@redhat.com>

	Do not suspend waitpid.
	strace used to suspend waitpid until there is a child
	for waitpid'ing process to collect status from.
	Apparently, it was done because in some very old kernels
	(circa 2002 or even earlier) there were ptrace bugs which
	were making waitpid in real parent to not see children.
	This kernel bug is fixed long ago. This change removes the workaround.
	test/wait_must_be_interruptible.c is a test program which
	illustrates why without this change strace changes
	programs's behavior.

	* defs.h: Delete waitpid and nclone_waiting members from from struct tcb.
	  Remove declaration of internal_wait().
	* process.c (internal_wait): Remove this function.
	* strace.c (alloc_tcb): Do not set tcp->nclone_waiting.
	  (resume): Remove this function.
	  (resume_from_tcp): Remove this function.
	  (detach): Do not call resume_from_tcp().
	  (handle_group_exit): Do not call resume_from_tcp().
	* syscall.c (internal_syscall): Do not call internal_wait().

2011-06-13  Andi Kleen  <ak@linux.intel.com>

	Enhance io_submit() decoding.
	strace didn't decode important fields in the iocb passed to io_submit.
	This patch changes the code to dump them all.  Also it prefixes the fields
	with names to make it easier to read.

	* desc.c (iocb_cmd_lookup, print_common_flags): New functions.
	(sys_io_submit): New iocb decoder.

2011-06-13  Dmitry V. Levin  <ldv@altlinux.org>

	Add argument to tprint_iov() specifying whether to decode each iovec.
	* defs.h (tprint_iov): Add decode_iov argument.
	* io.c (tprint_iov): Implement new decode_iov argument.
	(sys_readv, sys_writev, sys_sendfile, sys_preadv, sys_pwritev): Update
	tprint_iov calls.
	* net.c (do_msghdr): Likewise.

	Introduce ARRAY_SIZE() macro.
	* defs.h (ARRAY_SIZE): New macro.
	* ioctl.c: Use it.
	* pathtrace.c (pathmatch, storepath): Likewise.
	* process.c (printpriv): Likewise.
	* signal.c: Likewise.
	* syscall.c: Likewise.

2011-06-13  Andi Kleen  <ak@linux.intel.com>

	Fix decoding of timer id returned by timer_create.
	* time.c (sys_timer_create): The kernel returns a integer, not a
	pointer for the timer id in the memory pointed to by timer_id.

2011-06-09  Dmitry V. Levin  <ldv@altlinux.org>

	Add test for PTRACE_O_TRACESYSGOOD.
	* tests/ptrace_setoptions_for_all: New file.
	* tests/Makefile.am (TESTS): Add ptrace_setoptions_for_all.

	tests: update test for linux kernel version.
	* tests/ptrace_setoptions_followfork: Check for Linux kernel > 2.6.

	Update ptrace_setoptions test.
	The test have to be adjusted after commit v4.6-5-g3454e4b.

	* ptrace_setoptions: Update grep pattern, rename to
	ptrace_setoptions_followfork.
	* tests/Makefile.am (TESTS): Rename ptrace_setoptions to
	ptrace_setoptions_followfork.

	* strace.c (verror_msg): Rewrite without use of heap memory allocation.

	Fix MIPS syscall entries.
	* linux/mips/syscallent.h: Remove duplicate entries for 4336, 4337,
	and 4338 syscall numbers.

	Reported-by: Denys Vlasenko <dvlasenk@redhat.com>

2011-06-08  Denys Vlasenko  <dvlasenk@redhat.com>

	Don't display bogus parameter for sigreturn syscall.
	* linux/*/syscallent.h: For those arches which use sys_sigreturn,
	not printargs, to show [rt_]sigreturn syscall, change number of arguments
	from 1 to 0: sys_sigreturn function doesn't use syscall parameters.
	(I guess kernel doesn't actually _have_ any parameters for this syscall,
	at least on these architectures). Do the same change for I386 and x86-64
	even though they use printargs: I looked at kernel code and syscall
	definitely doesn't have any parameters on these arches.
	(I hesitate to change 1 to 0 params for arches I don't know -
	it is remotely possible some of them do have a parameter for this syscall).

	Optimize sigreturn handling.
	* signal.c (sys_sigreturn): move stack pointer variables,
	and for SPARC and MIPS, stack pointer and sigmask reading code
	into "if (entering) ..." block, because it is only needed
	in this branch; load tcp->u_arg[1] into sigmask for display
	_after_ we know for sure u_arg[1] does contain valid sigmask
	(IOW: perform operation only when we know we will need the result)

	Do not call umoven to fetch parameters if we have zero params.
	* syscall.c [I386] (syscall_enter): Do not call umoven
	to fetch zero bytes. This is just an optimization.

	"Modernize" four old-style function parameter declarations.
	* signal.c (signame, long_to_sigset, printsigmask, printsignal):
	Convert old-style C function definitions to a "modern" form.
	This does not change any actual code.

	Fix sigreturn decoding on MIPS.
	The "return 0" line was accidentally deleted circa 2007,
	which made sigreturn on MIPS always display "= 0" return
	instead of more informative " = ? (mask now [MASK])".

	* strace.c (sys_sigreturn): Add wrongly deleted "return 0" line

	Print at least one space between SYSCALL(ARGS) and = RESULT if tracee is killed
	We already do it in the normal case, but in rare code path where
	tracee is gone (SIGKILLed?) sometimes we were printing this:
	"SYSCALL(ARGS <unavailable>)= ? <unavailable>" - note jammed together ")=".
	test/sigkill_rain.c can be used to verify the fix.

	* strace.c (printleader): add a space after ")" in " <unavailable>)"

	Add fflush after printf in test/sigkill_rain.c.

	Update test/* directory, it seem to be a bit bit-rotted.
	Added README; modified sigkill_rain.c to be more understandable,
	made clone.c compile; added wait_must_be_interruptible.c test;
	updated Makefile and .gitignore.

2011-06-07  Denys Vlasenko  <dvlasenk@redhat.com>

	Whitespace cleanups. no code changes.
	* bjm.c: Fix tabulation (such as extra spaces before tabs),
	convert punctuation where it deviates from prevalent form
	elsewhere in strace code, convert sizeof and offsetof where
	it deviates from from prevalent form, remove space between
	function/macro/array names and (parameters) or [index],
	add space between "if" and (condition), correct non-standard
	or wrong indentaion.
	* defs.h: Likewise
	* desc.c: Likewise
	* file.c: Likewise
	* ipc.c: Likewise
	* linux/arm/syscallent.h: Likewise
	* linux/avr32/syscallent.h: Likewise
	* linux/hppa/syscallent.h: Likewise
	* linux/i386/syscallent.h: Likewise
	* linux/ioctlsort.c: Likewise
	* linux/m68k/syscallent.h: Likewise
	* linux/microblaze/syscallent.h: Likewise
	* linux/powerpc/syscallent.h: Likewise
	* linux/s390/syscallent.h: Likewise
	* linux/s390x/syscallent.h: Likewise
	* linux/sh/syscallent.h: Likewise
	* linux/sh64/syscallent.h: Likewise
	* linux/tile/syscallent.h: Likewise
	* linux/x86_64/syscallent.h: Likewise
	* mem.c: Likewise
	* net.c: Likewise
	* pathtrace.c: Likewise
	* process.c: Likewise
	* signal.c: Likewise
	* sock.c: Likewise
	* strace.c: Likewise
	* stream.c: Likewise
	* sunos4/syscall.h: Likewise
	* sunos4/syscallent.h: Likewise
	* svr4/syscall.h: Likewise
	* svr4/syscallent.h: Likewise
	* syscall.c: Likewise
	* system.c: Likewise
	* test/childthread.c: Likewise
	* test/leaderkill.c: Likewise
	* test/skodic.c: Likewise
	* time.c: Likewise
	* util.c: Likewise

2011-05-30  Dmitry V. Levin  <ldv@altlinux.org>

	ARM EABI: fix 64-bit syscall's arguments decoding.
	ARM OABI and ARM EABI have different function parameters passing rules.
	With EABI, 64-bit function parameters passed in registers are aligned to
	an even-numbered register instead of using the next available pair, see
	http://lkml.org/lkml/2006/1/12/175
	This rule also applies to syscall's arguments.

	* linux/arm/syscallent.h (pread, pwrite, truncate64, ftruncate64,
	readahead, preadv, pwritev): Fix number of arguments.
	* util.c (printllval): Align 64bit argument to 64bit boundary on
	__ARM_EABI__.

	Reported-by: Damir Shayhutdinov <damir@altlinux.org>

2011-05-30  Damir Shayhutdinov  <damir@altlinux.ru>

	Linux: implement decoding of preadv and pwritev syscalls.
	* io.c [LINUX && HAVE_SYS_UIO_H] (sys_preadv, sys_pwritev): New functions.
	* linux/syscall.h (sys_preadv, sys_pwritev): Declare them.
	* linux/*/syscallent.h: Use them.

2011-05-30  Denys Vlasenko  <dvlasenk@redhat.com>

	"Modernize" all old-style function parameter declarations.
	* bjm.c: Convert all remaining old-style C function definitions
	to a "modern" form. This does not change any actual code.
	* io.c: Likewise
	* ioctl.c: Likewise
	* net.c: Likewise
	* proc.c: Likewise
	* process.c: Likewise
	* signal.c: Likewise
	* sock.c: Likewise
	* strace.c: Likewise
	* stream.c: Likewise
	* syscall.c: Likewise
	* system.c: Likewise
	* time.c: Likewise
	* util.c: Likewise

2011-05-27  Denys Vlasenko  <dvlasenk@redhat.com>

	Cleanups on top of "handle SIGTRAP properly" change, based on Dmitry's comments.
	* defs.h ([p]error_msg[_and_die]): Declare new functions.
	* strace.c (SYSCALLTRAP): Rename to syscall_trap_sig.
	([p]error_msg[_and_die]): Define new functions.
	(strace_tracer_pid): New variable, it controls which pid will
	do cleanup on exit via [p]error_msg_and_die.
	(main): Set strace_tracer_pid to our initial pid.
	(startup_attach): Change strace_tracer_pid if we are in -D mode.
	(test_ptrace_setoptions_for_all): Minor changes to logic,
	such as better diagnostic messages.

2011-05-25  Denys Vlasenko  <dvlasenk@redhat.com>

	Identifier "errno" may be a macro, it's unsafe to use it.
	* strace.c (strerror): Rename parameter errno to err_no

2011-05-24  Denys Vlasenko  <dvlasenk@redhat.com>

	Don't perform TCB_WAITEXECVE wait if not needed.
	* defs.h (ptrace_setoptions_for_all): Expose this variable.
	* strace.c (ptrace_setoptions_for_all): Remove "static".
	* process.c (internal_exec): Don't set TCB_WAITEXECVE bit
	if we know that post-execve SIGTRAP is not going to happen.

2011-05-23  Denys Vlasenko  <dvlasenk@redhat.com>

	Properly handle real SIGTRAPs.
	* defs.h (ptrace_setoptions): Variable renamed to ptrace_setoptions_followfork.
	* process.c (internal_fork): Ditto.
	* strace.c (ptrace_setoptions_for_all): New variable.
	(SYSCALLTRAP): New variable.
	(error_msg_and_die): New function.
	(test_ptrace_setoptions_for_all): New function.
	(main): Call test_ptrace_setoptions_for_all() at init.
	(handle_ptrace_event): Handle PTRACE_EVENT_EXEC (by ignoring it).
	(trace): Check events and set ptrace options without -f too.
	Check WSTOPSIG(status) not for SIGTRAP, but for SYSCALLTRAP.

2011-04-24  Mike Frysinger  <vapier@gentoo.org>

	Blackfin: update syscall list.

	* linux/bfin/syscallent.h: Add name_to_handle_at, open_by_handle_at,
	clock_adjtime, and syncfs syscalls.

	linux: add new EHWPOISON errno.

	* linux/errnoent.h: Change ERRNO_133 to EHWPOISON.

2011-04-08  Grant Edwards  <grant.b.edwards@gmail.com>

	Add ability to print file descriptor paths and filter by those paths.
	* pathtrace.c: New file, implements matching syscall arguments to
	user-specified file paths.
	* Makefile.am (strace_SOURCES): Add pathtrace.c.
	* defs.h (TCB_FILTERED, filtered): New defines.
	(getfdpath, pathtrace_select, pathtrace_match, show_fd_path,
	tracing_paths): New declarations.
	* strace.c (show_fd_path, tracing_paths): New global variables.
	(usage, main): Implement handling of -y and -P options.
	* strace.1: Add descriptions of -y and -P options.
	* syscall.c (trace_syscall_entering): Add path matching logic to the
	print/noprint decision and set the TCB_FILTERED bit appropriately.
	(trace_syscall_exiting): Use filtered() macro that checks the
	TCB_FILTERED bit to determine print/noprint status.
	* util.c (printfd): Use getfdpath().

2011-04-07  Dmitry V. Levin  <ldv@altlinux.org>

	Fix BLKTRACESTOP definition.
	* block.c: Fix typo in the check for BLKTRACESTOP.
	Reported by Gabor Z. Papp.

2011-03-15  Dmitry V. Levin  <ldv@altlinux.org>

	Ensure that PTRACE_GETSIGINFO et al are always defined on Linux.
	* configure.ac (AC_CHECK_DECLS): Add PTRACE_* constants.
	* defs.h [LINUX]: Define those PTRACE_* constants that are not provided
	by <sys/ptrace.h>.

	* CREDITS.in: Fix typo.

2011-03-14  Dmitry V. Levin  <ldv@altlinux.org>

	Update PTRACE_* constants.
	* process.c (ptrace_cmds): Add PTRACE_GETREGSET and PTRACE_SETREGSET.

	Prepare for 4.6 release.
	* NEWS: Update for 4.6 release.
	* configure.ac: Version 4.6.
	* debian/changelog: 4.6-1.
	* strace.spec: 4.6-1.

2011-03-14  Mike Frysinger  <vapier@gentoo.org>

	linux/ioctlent: unify them all.
	This unifies all the ioctlent.h's in the linux subdir while still
	allowing each arch to maintain its own minor list.

	The basic method is:
	- each arch has linux/<arch>/ioctlent.h.in which defines only the
	arch-specific ioctls;
	- linux/ioctlent.h.in which defines only the common ioctls;
	- at build time, these two headers are combined and sorted to produce
	the linux/ioctlent.h file.

	This also requires a little tweaking of the include files since the
	common ioctlent.h is a built file.

	* linux/ioctlent.h: Split into linux/ioctlent.h.in and
	linux/i386/ioctlent.h.in, remove asm entries from the former, remove
	non-asm entries from the latter.
	* linux/alpha/ioctlent.h: Rename to linux/alpha/ioctlent.h.in, remove
	non-asm entries.
	* linux/bfin/ioctlent.h: Rename to linux/bfin/ioctlent.h.in, remove
	non-asm entries.
	* linux/hppa/ioctlent.h: Rename to linux/hppa/ioctlent.h.in, remove
	non-asm entries.
	* linux/ia64/ioctlent.h: Rename to linux/ia64/ioctlent.h.in, remove
	non-asm entries.
	* linux/mips/ioctlent.h: Rename to linux/mips/ioctlent.h.in, remove
	non-asm entries.
	* linux/powerpc/ioctlent.h: Rename to linux/powerpc/ioctlent.h.in,
	remove non-asm entries.
	* linux/s390/ioctlent.h: Rename to linux/s390/ioctlent.h.in, remove
	non-asm entries.
	* linux/sh/ioctlent.h: Rename to linux/sh/ioctlent.h.in, remove
	non-asm entries.
	* linux/sparc/ioctlent.h: Rename to linux/sparc/ioctlent.h.in, remove
	non-asm entries.
	* linux/arm/ioctlent.h.in: New file.
	* linux/avr32/ioctlent.h.in: Likewise.
	* linux/i386/ioctlent.h.in: Likewise.
	* linux/m68k/ioctlent.h.in: Likewise.
	* linux/microblaze/ioctlent.h.in: Likewise.
	* linux/tile/ioctlent.h.in: Likewise.
	* linux/x86_64/ioctlent.h.in: Likewise.
	* linux/s390x/ioctlent.h.in: Include ioctlent.h.in instead of
	ioctlent.h.
	* linux/sh64/ioctlent.h.in: Likewise.
	* linux/sparc64/ioctlent.h.in: Likewise.
	* linux/arm/ioctlent1.h: Update ioctlent.h include.
	* linux/powerpc/ioctlent1.h: Likewise.
	* linux/sparc/ioctlent1.h: Likewise.
	* linux/sparc64/ioctlent1.h: Likewise.
	* linux/x86_64/ioctlent1.h: Likewise.
	* Makefile.am (AM_CPPFLAGS): Add -I$(builddir)/$(OS).
	(EXTRA_DIST): Update.
	[MAINTAINER_MODE && LINUX]: Convert from ioctlent_h to ioctlent_h_in.
	[LINUX]: Add $(builddir)/$(OS)/ioctlent.h generation rules.
	* .gitignore: Add linux/ioctlent.h.

2011-03-10  Dmitry V. Levin  <ldv@altlinux.org>

	Show more details about signals received by traced processess.
	* strace.c [!USE_PROCFS] (trace): Differentiate output format depending
	on PTRACE_GETSIGINFO success or failure.  In the former case, use
	printsiginfo() to show more details about received signal.

	Get rid of PT_GETSIGINFO.
	* strace.c [!USE_PROCFS] (trace): Assume that PTRACE_GETSIGINFO is
	available.  Replace PT_GETSIGINFO with PTRACE_GETSIGINFO.  Use
	PTRACE_GETSIGINFO for all signals.

	Enhance decoding of kernel-generated signals.
	* signal.c (printsiginfo) [LINUX]: Do not print uninteresting
	zero-initialized fields.

	Fix decoding of user-generated signals.
	* signal.c [LINUX] (SI_FROMUSER): Define.
	[LINUX || SVR4] (printsiginfo) [SI_FROMUSER]: Enhance decoding.

	Recognize SI_KERNEL and SI_ASYNCNL.
	* signal.c [LINUX] (SI_KERNEL, SI_ASYNCNL): Define.
	[LINUX || SVR4] (siginfo_codes): Add entries for SI_KERNEL and
	SI_ASYNCNL, reorder entries.

2011-03-05  Sebastian Pipping  <sebastian@pipping.org>

	Take all git branches into account for generation of CREDITS file.
	* Makefile.am: Make CREDITS target depend on all git branches.

2011-03-04  Dmitry V. Levin  <ldv@altlinux.org>

	Fix decoding of file descriptors.
	* defs.h (printfd): New function prototype.
	* util.c (printfd): New function.
	* file.c (print_dirfd): Update prototype to use printfd().
	(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
	sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
	sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
	(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
	sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
	sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
	sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
	sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
	sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
	sys_fallocate): Use printfd() for decoding of file descriptors.
	* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
	decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
	decoding of file descriptors.
	* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
	sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
	sys_ioctl): Likewise.
	* mem.c (print_mmap, sys_mmap64): Likewise.
	* signal.c (do_signalfd): Likewise.
	* stream.c (decode_poll): Likewise.
	* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
	Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.

2011-03-03  Sebastian Pipping  <sebastian@pipping.org>

	Print shutdown(2) modes as SHUT_* constants.
	* net.c (shutdown_modes): New xlat structure.
	(sys_shutdown): Use shutdown_modes to decode 2nd syscall argument.

	Fix decoding of inotify_init1() flags.
	* file.c (inotify_init_flags): New xlat structure.
	(sys_inotify_init1): Use it instead of open_mode_flags.

2011-03-03  Dmitry V. Levin  <ldv@altlinux.org>

	Fix struct xlat initialization bugs.
	* file.c (inotify_modes): Terminate with NULL entry.
	* net.c (sock_type_flags): Make this array static.
	(socketlayers): Add a comment that this array should remain not
	NULL-terminated.

	tests: avoid SIGPIPE.
	* tests/ptrace_setoptions: Replace "grep -q" with "grep > /dev/null".
	The former may result to strace being killed by SIGPIPE, which in
	certain configuratons may lead to generation of a core file.
	Suggested by Mike Frysinger.

2011-03-01  Mike Frysinger  <vapier@gentoo.org>

	tests: do not make missing /usr/bin/time a failure.
	* tests/init.sh (framework_skip_): New function.
	(check_prog): Use it instead of framework_failure_.

2011-02-27  Dmitry V. Levin  <ldv@altlinux.org>

	Generate an xz tar archive of the distribution.
	* configure.ac (AM_INIT_AUTOMAKE): Replace dist-bzip2 with dist-xz.
	* Makefile.am: Update srpm target.
	* make-dist: Update for dist-xz.
	* strace.spec: Update Source tag.
	* debian/watch: Update regexp.
	* .gitignore: Add strace-*.tar.xz.

	Use "make check" in debian/rules and strace.spec.
	* debian/control: Update Build-Depends.
	* debian/rules: Run "make check".
	* strace.spec: Update BuildRequires. Run "make check" in %check section.

	Implement two basic "strace -f" tests.
	* Makefile.am (SUBDIRS): Add tests.
	* configure.ac (AC_CONFIG_FILES): Add tests/Makefile.
	* tests/.gitignore: New file.
	* tests/Makefile.am: Likewise.
	* tests/init.sh: Likewise.
	* tests/ptrace_setoptions: Likewise.
	* tests/strace-f: Likewise.

2011-02-26  Dmitry V. Levin  <ldv@altlinux.org>

	ppc, s390, sparc: regenerate ioctlent.h files.
	* linux/powerpc/ioctlent.h: Regenerated using Fedora 15 kernel headers.
	* linux/s390/ioctlent.h: Likewise.
	* linux/sparc/ioctlent.h: Likewise.

	Remove redundant ioctlent.h files.
	* linux/s390x/ioctlent.h: Replace old contents with include of
	s390/ioctlent.h file.
	* linux/sparc64/ioctlent.h: Replace old contents with include of
	sparc/ioctlent.h file.

2011-02-25  Dmitry V. Levin  <ldv@altlinux.org>

	ioctlsort: sync with ioctl_lookup()
	* linux/ioctlsort.c (main): Use NR and TYPE bits only, to sync with
	ioctl_lookup() which looks at these bits only.

	Remove obsolete .cvsignore files.
	* test/.cvsignore: Rename to test/.gitignore.
	* */.cvsignore, */*/.cvsignore: Removed.

	Ignore generated intermediate header files.
	* .gitignore: Add ioctls.h and ioctldefs.h.

2011-02-24  Dmitry V. Levin  <ldv@altlinux.org>

	Generate much of the CREDITS file from git log.
	* CREDITS.in: New file, derived from CREDITS, without names of
	those who are listed as git log 'Author:'s.
	* CREDITS: Remove file.
	* Makefile.am [MAINTAINER_MODE] (CREDITS): New rule.
	* .gitignore: Add CREDITS.
	* .mailmap: New file, required to map git author names and email
	addresses to canonical/preferred form.

2011-02-23  Dmitry V. Levin  <ldv@altlinux.org>

	sparc: fix compilation warning.
	* file.c [!HAVE_LONG_LONG_OFF_T] (realprintstat): Cast st_size
	to unsigned long.

	Update the list of files that must be distributed.
	* Makefile.am (EXTRA_DIST): Add debian/source/format, debian/watch,
	linux/ia64/signalent.h, linux/powerpc/ioctlent1.h,
	linux/powerpc/syscallent1.h, linux/powerpc/errnoent1.h,
	linux/powerpc/signalent1.h.

	Fix compilation warning reported by gcc -Wunused-but-set-variable.
	* process.c (printwaitn) [!SUNOS4]: Do not define "exited" variable.

2011-02-22  Mike Frysinger  <vapier@gentoo.org>

	ioctlsort: zero pad ioctl codes to 4 places.
	Zero padding the ioctl number will allow simple sorting via shell scripts.

	* linux/ioctlsort.c (main): Output ioctl codes zero padded.
	* linux/ioctlent.h: Regenerated.

	Update mount flags to latest linux.
	* system.c (MS_RELATIME, MS_KERNMOUNT, MS_I_VERSION,
	MS_STRICTATIME, MS_BORN): Define.
	(mount_flags): Add MS_RELATIME, MS_KERNMOUNT, MS_I_VERSION,
	MS_STRICTATIME, MS_BORN.

2011-02-22  Dmitry V. Levin  <ldv@altlinux.org>

	Sync debian/changelog and strace.spec with packages.
	* debian/changelog: Sync with 4.5.20-2.
	* strace.spec: Likewise.

2011-02-20  Dmitry V. Levin  <ldv@altlinux.org>

	Add TRACE_DESC|TRACE_FILE flags to fanotify_* sysentries.
	* linux/*/syscallent.h: Add TD flag to fanotify_init.  Add TD|TF flags
	to fanotify_mark.

	Fix flags of fallocate sysentries.
	* linux/*/syscallent.h: Fix sys_fallocate flags.

	Add TRACE_DESC flag to epoll_create* sysentries.
	* linux/*/syscallent.h: Add TD flag to sys_epoll_create and
	sys_epoll_create1.

	Add TRACE_DESC flag to fgetxattr, flistxattr, and fremovexattr sysentries
	* linux/*/syscallent.h: Add TD flag to sys_fgetxattr, sys_flistxattr,
	and fremovexattr.

	Add TRACE_FILE flag to swapoff sysentries.
	* linux/*/syscallent.h: Add TF flag to sys_swapoff.

	Add TRACE_DESC flag to fadvise64* sysentries.
	* linux/*/syscallent.h: Add TD flag to sys_fadvise64 and
	sys_fadvise64_64.

	Add TRACE_DESC flag to mmap, mmap2, and old_mmap sysentries.
	* linux/*/syscallent.h: Add TD flag to sys_mmap and sys_old_mmap.

	Do not initialize native_scno on platforms with only one personality.
	* linux/bfin/syscallent.h: Remove redundant native_scno initialization.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.

	Add LOOP_* ioctls defined in linux/loop.h.
	* linux/ioctlent.sh: Add LOOP_* ioctls (0x4C..) defined in linux/loop.h
	header file.
	* linux/ioctlent.h: Regenerated.
	Reported by Mike Frysinger.

2011-02-19  Dmitry V. Levin  <ldv@altlinux.org>

	Fix PTRACE_GETEVENTMSG usage and enhance test_ptrace_setoptions()
	* strace.c (handle_ptrace_event): Fix PTRACE_GETEVENTMSG usage.
	(test_ptrace_setoptions): Test that PTRACE_GETEVENTMSG works properly.

2011-02-19  Mike Frysinger  <vapier@gentoo.org>

	linux/sparc: move to common syscall.h.
	Rather than constantly deal with the sparc/syscall.h going stale, merge
	the few sparc-specific pieces into the linux/syscall.h header.

	* linux/syscall.h: Add sparc-specific pieces from sparc/syscall.h.
	* Makefile.am (EXTRA_DIST): Remove linux/sparc/syscall.h and
	linux/sparc64/syscall.h.
	* linux/sparc/syscall.h, linux/sparc64/syscall.h: Deleted.

	sparc: add new funcs to syscall.h.
	Sync missing defs from the common syscall.h here.

	* linux/sparc/syscall.h: Add sys_setfsuid, sys_pread64, and
	sys_pwrite64 prototypes.

	sparc: punt unused syscall.h.2.
	I can't find any mention of this header actually being used.
	Seems to be a really old copy of the common syscall.h.

	* Makefile.am (EXTRA_DIST): Remove linux/sparc/syscall.h.2.
	* linux/sparc/syscall.h.2: Deleted.

2011-02-19  Dmitry V. Levin  <ldv@altlinux.org>

	Fix raw exit_group(2) decoding.
	* syscall.c (trace_syscall_entering): Check for sys_exit instead of
	SYS_exit to handle exit_group(2) as well as _exit(2).

2011-02-18  Dmitry V. Levin  <ldv@altlinux.org>

	Optimize known_scno()
	* syscall.c (known_scno): Do not check for native_scno field on
	platforms that support only one personality.

	* process.c (internal_exit) [IA64]: Remove redundant check.

2011-02-09  Dmitry V. Levin  <ldv@altlinux.org>

	Fix biarch support in IO dumping.
	* syscall.c (dumpio): Switch on tcp->sys_func instead of tcp->scno
	for more reliable results.

	Simplify tprintf() declaration.
	* defs.h (tprintf): Simplify declaration.

2011-02-05  Dmitry V. Levin  <ldv@altlinux.org>

	* defs.h (SYSCALL_NEVER_FAILS): Fix typo.

2011-01-19  Dmitry V. Levin  <ldv@altlinux.org>

	Fix decoding of get[ug]id, gete[ug]id and setfs[ug]id return values.
	* defs.h (SYSCALL_NEVER_FAILS): New syscall flag.
	* linux/dummy.h: Change redirection for sys_get[ug]id, sys_gete[ug]id
	and setfs[ug]id.
	* linux/*/syscallent.h: Set SYSCALL_NEVER_FAILS flag for get[ug]id,
	gete[ug]id and setfs[ug]id syscalls.
	* process.c [LINUX] (sys_getuid, sys_setfsuid): New functions.
	* syscall.c (NF): New shorthand macro for use in syscallent.h files.
	(get_error): Check SYSCALL_NEVER_FAILS flag.
	Reported by Марк Коренберг <socketpair@gmail.com>.

	* linux/*/syscallent.h: Fix typo in sys_newfstatat syscall flags.

2011-01-18  Mike Frysinger  <vapier@gentoo.org>

	Blackfin: update ioctl list.
	* linux/bfin/ioctlent.h: Sync with latest kernel sources.

2011-01-17  Dmitry V. Levin  <ldv@altlinux.org>

	Fix stat64 decoding on mips.
	* linux/mips/syscallent.h: Use sys_stat64() to decode stat64 syscall.
	This fixes Debian bug #599028.

	Update linux/*/syscallent.h files to match Linux kernel v2.6.37.
	* linux/alpha/syscallent.h: Add hooks for fanotify_init, fanotify_mark,
	and prlimit64.
	* linux/i386/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/microblaze/syscallent.h: Likewise.
	* linux/mips/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	* linux/arm/syscallent.h: Add hooks for accept4, fanotify_init,
	fanotify_mark, and prlimit64.
	* linux/hppa/syscallent.h: Add hook for prlimit64.

2011-01-16  Dmitry V. Levin  <ldv@altlinux.org>

	block.c: cleanup.
	* block.c: Include <inttypes.h>.
	(print_blkpg_req): Always decode struct blkpg_ioctl_arg.
	Robustify decoding of strings.
	(block_ioctl): Do not decode return values passed by pointers on exit
	from failed syscalls.
	Use format macros from inttypes.h to print values of type uint64_t.

2011-01-15  Dmitry V. Levin  <ldv@altlinux.org>

	Add block ioctl support.
	* block.c: New file.
	* Makefile.am (strace_SOURCES): Add it.
	* defs.h [LINUX] (block_ioctl): New function.
	* ioctl.c (ioctl_decode) [LINUX]: Use it to decode HDIO_* and BLK*
	ioctls.
	Patch by Jeff Mahoney <jeffm@suse.com>

2011-01-14  Holger Hans Peter Freyther  <zecke@selfish.org>

	Parse SOL_SCTP socket options.
	* configure.ac (AC_CHECK_HEADERS): Add netinet/sctp.h.
	* net.c [HAVE_NETINET_SCTP_H]: Include <netinet/sctp.h>.
	[SOL_SCTP] (socksctpoptions): New xlat structure.
	(sys_getsockopt, printsockopt): Parse SOL_SCTP options.

	* net.c (socketlayers): Add more SOL_* constants from linux/socket.h.

2011-01-14  Dmitry V. Levin  <ldv@altlinux.org>

	strace.1: fix misleading italics.
	* strace.1: Use bold instead of italics for "-e trace=" keywords.
	This fixes Debian bug #589323.

	Update linux/ioctlent.h.
	* linux/ioctlent.h: Regenerate using linux v2.6.37 headers.

	Add HDIO_* ioctls defined in linux/hdreg.h.
	* linux/ioctlent.sh: Add HDIO_* ioctls (0x03..) defined in
	linux/hdreg.h header file.
	This fixes Debian bug #450953.

2011-01-13  Dmitry V. Levin  <ldv@altlinux.org>

	Test PTRACE_O_TRACECLONE and PTRACE_O_TRACEVFORK along with PTRACE_O_TRACEFORK
	* strace.c (test_ptrace_setoptions): Add PTRACE_O_TRACECLONE and
	PTRACE_O_TRACEVFORK to PTRACE_SETOPTIONS call, to test exactly
	the same set of options that is going to be used later in trace().

2011-01-10  Dmitry V. Levin  <ldv@altlinux.org>

	* net.c (protocols): Add more IPPROTO_* constants defined in netinet/in.h

2011-01-10  Holger Hans Peter Freyther  <holger@freyther.de>

	* net.c (protocols): Add IPPROTO_GRE, IPPROTO_SCTP and IPPROTO_UDPLITE.

2011-01-10  Carmelo AMOROSO  <carmelo.amoroso@st.com>

	sh: Add entry for not-multiplexed accept4.
	* linux/sh/syscallent.h: Add specific entry for not-multiplexed accept4
	available in kernel mainline since v2.6.37-rc6, see
	http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=21b6e4c7106b2d68a6710506d8706608272fd78b

2010-12-14  Carmelo AMOROSO  <carmelo.amoroso@st.com>

	sh: Add entries for not-multiplexed socket calls.
	* linux/sh/syscallent.h: Add specific entries for not-multiplexed
	socket calls (available in kernel mainline since v2.6.37-rc1)

	sh: Fix compilation warning in do_pipe due to missing prototype.
	* defs.h [SH]: Make getrval2 prototype visible to do_pipe
	and fix the following compiler warning:
	.../net.c: In function 'do_pipe':
	.../net.c:1632: warning: implicit declaration of function 'getrval2'
	.../net.c:1632: warning: format '%lu' expects type 'long unsigned int',
	but argument 3 has type 'int'

2010-12-14  Dmitry V. Levin  <ldv@altlinux.org>

	Fix build on uClibc.
	* defs.h [LINUX]: Define PTRACE_GETEVENTMSG macro.
	Patch by Douglas Mencken <dougmencken@gmail.com>.

2010-12-07  Dmitry V. Levin  <ldv@altlinux.org>

	Fix strace -f -o '|command' hangup.
	* strace.c (main): Call test_ptrace_setoptions() before parsing
	-o option, otherwise a forked command will cause a hangup inside
	test_ptrace_setoptions().

2010-12-03  Dmitry V. Levin  <ldv@altlinux.org>

	Output diagnostics to stderr.
	* syscall.c (get_scno): Output information about changes in
	personality mode to stderr.  Reported by Pádraig Brady.

	Recognize more clone flags.
	* process.c (CLONE_*): Define more flags from linux v2.6.25.
	(clone_flags): Add entries for them.
	Proposed by <zhangyanfei@cn.fujitsu.com>.

	Decode struct ucred for getsockopt SO_PEERCRED.
	* net.c (sys_getsockopt): Decode SO_PEERCRED.
	Proposed by Arkadiusz Miśkiewicz <arekm@maven.pl>.

2010-12-03  Carmelo AMOROSO  <carmelo.amoroso@st.com>

	sh: Add support for tracing sys_cacheflush system call.
	* linux/sh/syscallent.h: Update sys_cacheflush entry.
	* linux/syscall.h [SH] (sys_cacheflush): New function declaration.
	* system.c [SH] (cacheflush_flags): New xlat structure.
	[SH] (sys_cacheflush): New function.

	Reviewed-by: Angelo Castello <angelo.castello@st.com>

2010-11-30  Dmitry V. Levin  <ldv@altlinux.org>

	Cleanup test_ptrace_setoptions()
	* strace.c (test_ptrace_setoptions): Cleanup.
	(main): Fix test_ptrace_setoptions() error diagnostics message.
	Print ptrace_setoptions value in debug mode.

2010-11-30  Wang Chao  <wang.chao@cn.fujitsu.com>

	Handle followfork using ptrace_setoptions if available.
	If PTRACE_O_TRACECLONE et al options are supported by kernel,
	use them to do followfork rather than the original setbpt
	method that changes registers ourselves.

	* defs.h [LINUX] (handle_new_child): New function prototype.
	* process.c [LINUX] (handle_new_child): New function based on the
	code from internal_fork(), with a trivial change: do reparent only
	for sys_clone.
	[LINUX] (internal_fork): Use handle_new_child().  Do nothing if
	ptrace_setoptions is in effect.
	* strace.c [LINUX] (handle_ptrace_event): New function.
	[LINUX] (trace): If ptrace_setoptions is in effect, then
	call the new function to handle PTRACE_EVENT_* status, and
	set PTRACE_SETOPTIONS when we see the initial stop of tracee.

	Test how PTRACE_SETOPTIONS support works.
	Currently test fork related options only.  Fork a child that uses
	PTRACE_TRACEME at startup and then does a fork so strace can test
	how the PTRACE_SETOPTIONS support works before it handles any real
	tracee.  Since PTRACE_O_TRACECLONE/*FORK were introduced to kernel
	at the same time, this test seems to be enough for these 3 options.

	* defs.h [LINUX]: Define PTRACE_O_TRACECLONE et al macros here.
	(ptrace_setoptions): New variable declaration.
	* strace.c [LINUX] (test_ptrace_setoptions): New function, tests
	whether kernel supports PTRACE_O_CLONE/*FORK, the result is stored
	in the new variable ptrace_setoptions for later use.
	(main): Call test_ptrace_setoptions() if followfork option is set.

2010-09-17  Dmitry V. Levin  <ldv@altlinux.org>

	Enable support for less verbose build rules.
	* configure.ac (AM_INIT_AUTOMAKE): Add silent-rules.

2010-09-17  Wang Chao  <wang.chao@cn.fujitsu.com>

	Do not trace children cloned with CLONE_UNTRACED flag.
	If clone is called with flag CLONE_UNTRACED, to be consistent with
	option PTRACE_O_TRACECLONE, we should not set CLONE_PTRACE flag on
	its arguments.

	* process.c [LINUX] (internal_fork): Check the syscall and arguments.

2010-09-17  Dmitry V. Levin  <ldv@altlinux.org>

	Update the list of CLOCK_* constants to match Linux kernel v2.6.32+
	* time.c (struct xlat clocknames[]): Add more RT clock IDs.
	Reported by Tommi Rantala.

2010-09-16  Dmitry V. Levin  <ldv@altlinux.org>

	Update linux/hppa/syscallent.h to match Linux kernel v2.6.35.
	* linux/hppa/syscallent.h: Add hooks for recvmmsg and accept4.

2010-09-15  Dmitry V. Levin  <ldv@altlinux.org>

	Pass less information to qualify_one and qual_*
	* syscall.c (qualify_one, qual_syscall, qual_signal, qual_fault,
	qual_desc): Take just a bitflag argument instead of pointer to the whole
	qual_options structure.
	(struct qual_options): Update prototype of "qualify" field.
	(qualify): Update use of qualify_one and qual_options->qualify.

2010-09-15  Wang Chao  <wang.chao@cn.fujitsu.com>

	Fix -e option with only one value in qualifier statement.
	Fix regression introduced by commit v4.5.20-19-g30145dd:
	if -e option is used with only one value in qualifier statement,
	e.g. 'strace -e trace=open ls', syscall information would not be
	printed properly.

	* syscall.c (qualify): Remove faulty optimization.

2010-09-15  Mike Frysinger  <vapier@gentoo.org>

	Fix off_t/rlim_t size checks when cross-compiling.
	The current off_t/rlim_t size checks (wrt size of long long) use AC_RUN
	which obviously doesn't work when cross-compiling.  While we don't hit
	any configure errors, the fall back code is pretty dumb (which is to say
	there isn't any).  Considering the code in question though, we can use
	some fun compiler tricks with sizeof and array lengths to turn it into
	a pure build test and avoid the RUN issue completely.

	* m4/long_long.m4 (AC_OFF_T_IS_LONG_LONG, AC_RLIM_T_IS_LONG_LONG):
	Convert from AC_RUN_IFELSE to AC_COMPILE_IFELSE.

	Fix long long little endian detection when cross-compiling.
	The long long endian detection code does an AC_TRY_RUN() and since that
	doesn't work when cross-compiling, it sets a fallback value.  However,
	rather than do any sort of default endian detection, the code simply
	sets it to "no".  This probably breaks most little endian systems out
	there when cross-compiling for them.  It certainly breaks Blackfin
	systems.  So use the common endian detection code provided by autoconf
	and key off of that when cross-compiling.

	* configure.ac: Call AC_C_BIGENDIAN.
	* m4/long_long.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Set cross-compiling
	logic based on ac_cv_c_bigendian.

	Blackfin: decode new syscalls.
	* linux/bfin/syscallent.h: Add fanotify/prlimit/cacheflush syscalls.
	* linux/syscall.h: Add sys_cacheflush() decl.
	* system.c: Decode Blackfin's cacheflush syscall.

	* linux/ioctlent.sh: Search a few non-exported paths.

2010-09-15  Roland McGrath  <roland@redhat.com>

	Clean up pid2tcb usage.
	* strace.c (pid2tcb): Always match pid.  Fail for argument <= 0.
	[USE_PROCFS] (first_used_tcb): New function.
	[USE_PROCFS] (trace): Use that instead of pid2tcb(0).

2010-09-09  Dmitry V. Levin  <ldv@altlinux.org>

	Turn on more compiler warnings.
	* configure.ac: Enable gcc -Wwrite-strings.

	Import warnings.m4 from gnulib.
	* m4/warnings.m4: Replace with warnings.m4 from gnulib.
	* configure.ac: Use gl_WARN_ADD from new warnings.m4.
	* Makefile.am (AM_CFLAGS): Update for new warnings.m4.

	Split acinclude.m4.
	* Makefile.am (ACLOCAL_AMFLAGS): Add "-I m4".
	* acinclude.m4: Remove.
	* m4/includedir.m4: New file, with definition of AC_INCLUDEDIR from
	acinclude.m4.
	* m4/long_long.m4: New file, with definitions of AC_OFF_T_IS_LONG_LONG,
	AC_RLIM_T_IS_LONG_LONG and AC_LITTLE_ENDIAN_LONG_LONG from acinclude.m4.
	* m4/procfs.m4: New file, with definitions of AC_MP_PROCFS,
	AC_POLLABLE_PROCFS and AC_STRUCT_PR_SYSCALL from acinclude.m4.
	* m4/stat.m4: New file, with definition of AC_STAT64 from acinclude.m4.
	* m4/statfs.m4: New file, with definition of AC_STATFS64 from
	acinclude.m4.
	* m4/warnings.m4: New file, with definition of AC_WARNFLAGS from
	acinclude.m4.

	* process.c (sys_waitid): Remove unused variable.

2010-09-07  Dmitry V. Levin  <ldv@altlinux.org>

	Fix const-correctness issues uncovered by gcc -Wwrite-strings.
	* defs.h (struct xlat): Add const qualifier to the field of
	type "char *".
	(set_sortby, qualify, printnum, printnum_int): Add const qualifier to
	arguments of type "char *".
	* count.c (set_sortby): Add const qualifier to the argument and
	automatic variable of type "char *".
	* desc.c (decode_select): Add const qualifier to automatic variables of
	type "char *".
	* ioctlsort.c (struct ioctlent): Add const qualifier to fields of
	type "char *".
	(main):  Add const qualifier to argv.
	* process.c (printargv): Add const qualifier to the argument and
	automatic variable of type "char *".
	(printargc) Add const qualifier to argument of type "char *".
	* signal.c (sprintsigmask, parse_sigset_t): Add const qualifier to
	arguments of type "char *".
	* strace.c (progname): Add const qualifier.
	(detach): Add const qualifier to automatic variable of type "char *".
	* stream.c (struct strbuf): Add const qualifier to the field of
	type "char *".
	* syscall.c (struct qual_options): Add const qualifier to fields of
	type "char *".
	(qual_syscall, qual_fault, qual_desc, lookup_class): Add const qualifier
	to arguments of type "char *".
	(qual_signal): Add const qualifier to the argument of type "char *",
	avoid modification of constant argument.
	(qualify): Likewise.
	* util.c (printflags): Add const qualifier to automatic variable of
	type "char *".
	(printnum, printnum_int): Add const qualifier to arguments of
	type "char *".

2010-09-04  Wang Chao  <wang.chao@cn.fujitsu.com>

	Fix printing clone flags.
	When we trace clone() syscall with only exit signal as clone
	flags, strace would print an unnecessary OR operator.

	* process.c (sys_clone): Fix this.

2010-08-28  Wang Chao  <wang.chao@cn.fujitsu.com>

	Drop nclone_detached and related flags.
	Remove nclone_detached since CLONE_DETACHED flag was no-op for a very
	long time in kernel.

	* defs.h (struct tcb): Remove nclone_detached field.
	Remove TCB_CLONE_DETACHED flag.
	* process.c: Remove CLONE_DETACHED flag.
	(clone_flags): Remove CLONE_DETACHED entry.
	(internal_fork, internal_wait): Remove code dealing with CLONE_DETACHED
	flag and nclone_detached.
	* strace.c (startup_attach, alloc_tcb, droptcb, handle_group_exit):
	Likewise.

2010-08-09  Neil Campbell  <lists@thebatcave.org.uk>

	Correct get/set_robust_list syscall numbers for powerpc.
	* linux/powerpc/syscallent.h: Swap positions of get_ and set_robust_list.

2010-08-09  Wang Chao  <wang.chao@cn.fujitsu.com>

	Handle CLONE_PARENT flag.
	* process.c (internal_fork): The parent of new cloned process is the
	same of the calling process when CLONE_PARENT is set.

	Fix error when judging if process has children.
	* process.c (internal_wait): Processes counted in tcp->nclone_threads
	are tcp's threads, rather than tcp's children.

	Forbid using mutually exclusive options -D and -p together.
	If we use -D and -p option together to trace a multi-thread program, in
	addition to the main thread, other threads could not be traced even if we
	present -f option. Moreover, when executing 'strace -D -p <non-exist pid>',
	strace could not terminate normally.

	* strace.c (main): Check it.

2010-08-05  David Daney  <ddaney@caviumnetworks.com>

	Update Linux MIPS syscalls to match 2.6.35-rc6+
	* linux/mips/syscallent.h: Add and update 405 hooks.

2010-08-05  Edgar E. Iglesias  <edgar.iglesias@gmail.com>

	Add support for the MicroBlaze architecture.
	* configure.ac: Recognize MicroBlaze.
	* linux/microblaze/syscallent.h: New file.
	* Makefile.am (EXTRA_DIST): Add linux/microblaze/syscallent.h
	* process.c (change_syscall, struct_user_offsets): Add MicroBlaze
	support.
	* signal.c (sys_sigreturn): Likewise.
	* syscall.c (internal_syscall, get_scno, syscall_fixup, get_error,
	syscall_enter): Likewise.

2010-08-05  Frederik Schüler  <fs@debian.org>

	linux/sparc: add missing syscall declarations.
	* linux/sparc/syscall.h: Sync with linux/syscall.h

2010-07-17  Andreas Schwab  <schwab@linux-m68k.org>

	Handle biarch get/setrlimit.
	* resource.c (print_rlimit32) [POWERPC64 || X86_64]: Define.
	(sys_getrlimit, sys_setrlimit) [POWERPC64 || X86_64]: Use it.

2010-07-13  Andreas Schwab  <schwab@linux-m68k.org>

	Add biarch support for powerpc64.
	* acinclude.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Use int instead of
	long.
	* configure.ac [$host_cpu = powerpc*]: Also define POWERPC64 if
	$host_cpu = powerpc64.
	* defs.h (SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE)
	(PERSONALITY1_WORDSIZE) [POWERPC64]: Define.
	* file.c: (struct stat_powerpc32, printstat_powerpc32) [POWERPC64]:
	Define.
	(printstat) [LINUX && POWERPC64]: Use printstat_powerpc32 in
	32-bit personality.
	(sys_newfstatat) [POWERPC64]: Handle personalities.
	* signal.c (sys_sigreturn) [POWERPC64]: Likewise.
	* util.c (printllval) [POWERPC64]: Likewise.
	(printcall) [POWERPC64]: Use wider format for IP prefix.
	* syscall.c (get_scno) [POWERPC64]: Check for 64/32 bit mode.
	* linux/powerpc/errnoent1.h: New file.
	* linux/powerpc/ioctlent1.h: New file.
	* linux/powerpc/signalent1.h: New file.
	* linux/powerpc/syscallent1.h: New file.

2010-07-09  Andreas Schwab  <schwab@redhat.com>

	Balance braces.
	* strace.c (proc_open): Avoid unbalanced braces.
	(trace): Likewise.

2010-07-06  Andreas Schwab  <schwab@linux-m68k.org>

	Remove extern declaration at file scope.
	* defs.h (force_result): Declare.
	* process.c (internal_wait): Don't declare force_result.

2010-06-24  Andreas Schwab  <schwab@redhat.com>

	Document -C/-D.
	* strace.c (usage): Document -C.
	* strace.1: Document -D.

2010-06-13  Roland McGrath  <roland@redhat.com>

	Fix sourceforge download URL.

2010-06-05  Andreas Schwab  <schwab@linux-m68k.org>

	M68K: Fix fetching syscall arguments.
	* syscall.c (syscall_enter) [M68K]: Properly handle more than five
	syscall arguments.

2010-05-28  Andreas Schwab  <schwab@linux-m68k.org>

	Decode TLS syscalls on m68k.
	* linux/m68k/syscallent.h: Add entries for get_thread_area,
	set_thread_area, atomic_comxchg_32, atomic_barrier.
	* linux/dummy.h (sys_get_thread_area, sys_set_thread_area) [M68K]:
	Don't redefine.
	* mem.c (sys_get_thread_area, sys_set_thread_area) [LINUX && M68K]: New.

	Fix warning when compiling for m68k.
	* syscall.c (d0): Define as long.

2010-04-13  Dmitry V. Levin  <ldv@altlinux.org>

	Prepare for 4.5.20 release.
	* NEWS: Update for 4.5.20 release.
	* configure.ac: Version 4.5.20.
	* debian/changelog: 4.5.20-1.
	* strace.spec: 4.5.20-1.

2010-04-13  Frederik Schüler  <fs@debian.org>

	Update debian/* files for the upcoming release.
	* debian/control: update standards-version to 3.8.4.
	* debian/rules: allow parallel building.
	* debian/rules: comment out verbose build, only needed for debugging.
	* debian/rules: clean up clean: target, dh_clean does most of the work
	  already.
	* debian/rules: use *-stamp instead of stamp-*, so dh_clean can tidy
	  up for us.

2010-04-13  Heiko Carstens  <heiko.carstens@de.ibm.com>

	Fix s390 system call table list.
	* linux/s390/syscallent.h: Add the missing entries for preadv and
	pwritev to the system call table list.
	* linux/s390x/syscallent.h: Likewise.

2010-04-07  Dmitry V. Levin  <ldv@altlinux.org>

	Update linux/ioctlent.h.
	* linux/ioctlent.sh: Search in asm-generic directory as well.
	* linux/ioctlent.h: Regenerated.

	Update linux/*/syscallent.h files to match Linux kernel v2.6.33.
	* linux/alpha/syscallent.h: Add 47 hooks.
	* linux/arm/syscallent.h: Update hooks for pselect6, ppoll,
	epoll_pwait.  Add 11 hooks.
	* linux/bfin/syscallent.h: Update hooks for prctl, fallocate,
	signalfd4, eventfd2, epoll_create1, dup3, pipe2, perf_event_open.
	Hook up recvmmsg.
	* linux/hppa/syscallent.h: Update hooks for signalfd4, eventfd2,
	epoll_create1, dup3, pipe2, perf_event_open.
	* linux/i386/syscallent.h: Fix syscall name for the kexec_load hook.
	Add 5 hooks.
	* linux/ia64/syscallent.h: Fix syscall name for the kexec_load hook.
	Add 4 hooks.
	* linux/m68k/syscallent.h: Add 50 hooks.
	* linux/powerpc/syscallent.h: Fix hook for timerfd_create.  Fix
	6 syscall names to match the kernel.  Use sys_semop to parse semop.
	Add 14 hooks.
	* linux/s390/syscallent.h: Fix syscall name for the kexec_load hook.
	Add 14 hooks.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Add 13 hooks.
	* linux/sh64/syscallent.h: Add 15 hooks.
	* linux/sparc/syscallent.h: Add 22 hooks.
	* linux/x86_64/syscallent.h: Add 5 hooks.

	Enhance recvmmsg parser.
	* net.c (sys_recvmmsg): Decode mmsghdr structure on exit from the
	syscall.  Decode timespec structure both on entrance and on exit.

2010-04-07  Andreas Schwab  <schwab@linux-m68k.org>

	Decode recvmmsg syscall.
	* net.c (do_msghr): New function to print struct msghdr.
	(printmsghdr): Use it.
	(printmmsghdr, sys_recvmmsg): New.
	* linux/syscall.h: Declare sys_recvmmsg.
	(SYS_sub_recvmmsg): Define.
	(SYS_socket_nsubcalls): Bump.
	* linux/sparc/syscall.h: Likewise.
	* linux/arm/syscallent.h: Add sys_recvmmsg.
	* linux/bfin/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/m68k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Adjust.

2010-04-07  Dmitry V. Levin  <ldv@altlinux.org>

	* strace.1: Fix quoting of hyphens and formatting of strace options.

	Split trace_syscall() for better readability.
	* syscall.c (trace_syscall): Split into trace_syscall_exiting() and
	trace_syscall_entering().

	Implement -C option to combine regular and -c output.
	* defs.h (cflag_t): New enum.
	* strace.1: Document -C option.
	* strace.c (cflag): Update type.
	(main): Handle -C option.
	(trace): Update use of cflag.
	* count.c (count_syscall): Move clearing of TCB_INSYSCALL to ...
	* syscall.c (trace_syscall): ... here.  Update use of cflag.
	Based on patch by Adrien Kunysz.

	Fix "make dist" regression introduced by commit v4.5.19-12-g5078770.
	* Makefile.am (EXTRA_DIST): Rename linux/syscallent.h to linux/i386/syscallent.h

	* desc.c (sys_epoll_pwait): Fix output formatting bug.

	* desc.c (decode_select): Fix potential stack buffer overflow.

2010-03-31  Dmitry V. Levin  <ldv@altlinux.org>

	Fix msgsnd indirect ipccall decoding.
	This regression was introduced by commit v4.5.18-136-g783f5bc.
	* ipc.c (tprint_msgsnd): Add and use "flags" argument.
	(sys_msgsnd): Pass "flags" argument to tprint_msgsnd().
	Patch by Anton Blanchard.

2010-03-23  Mark Wielaard  <mjw@redhat.com>

	Hook up inotify_init1 open mode flags printer.
	* file.c [LINUX] (sys_inotify_init1): New function.
	* linux/syscall.h: Declare new sys_inotify_init1 handler.
	* linux/bfin/syscallent.h: Hook up new handler.
	* linux/hppa/syscallent.h: Likewise.
	* linux/i386/syscallent.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.

2010-03-09  Andreas Schwab  <schwab@redhat.com>

	Avoid spurious error when checking for linux/netlink.h.
	* configure.ac: Include <asm/types.h> when checking for
	linux/netlink.h.

2010-02-23  Andreas Schwab  <schwab@linux-m68k.org>

	Fix reporting signal mask by sigreturn on powerpc.
	* signal.c (sys_sigreturn) [POWERPC]: Skip dummy stack frame when
	locating signal context.

2010-02-09  David Daney  <ddaney@caviumnetworks.com>

	Fix MIPS N32/N64 compile error.
	* syscall.c [LINUX_MIPSN32 || LINUX_MIPSN64] (syscall_enter): Pass
	tcp->pid to ptrace().

2010-02-05  Chris Metcalf  <cmetcalf@tilera.com>

	Add support for the TILE architecture.
	* configure.ac: Add TILE to the list of supported architectures.
	* defs.h: Define TCB_WAITEXECVE for TILE.
	* linux/tile/syscallent.h: New file.
	* Makefile.am (EXTRA_DIST): Add linux/tile/syscallent.h
	* process.c (change_syscall, struct_user_offsets): Add TILE support.
	* syscall.c (get_scno, get_error, syscall_enter): Likewise.
	* mem.c (mmap_flags, print_mmap): Add MAP_CACHE_xxx TILE extensions
	support.
	* signal.c (sigact_flags): Add SA_NOPTRACE.
	(sys_sigreturn): Add TILE support.

2010-02-04  Dmitry V. Levin  <ldv@altlinux.org>

	Remove dead code.
	* defs.h (tv_tv): Remove.
	* net.c (sys_xsetsockaddr): Remove commented out dead code.
	* process.c (setarg, sys_execv, sys_execve, struct_user_offsets):
	Likewise.
	* signal.c (sys_sigsuspend): Likewise.
	* strace.c (reaper, trace): Likewise.
	* stream.c (internal_stream_ioctl): Likewise.
	* syscall.c (trace_syscall): Likewise.
	* term.c (term_ioctl): Likewise.
	* util.c (tv_tv, umoven, uload, getpc, fixvfork, setbpt, clearbpt):
	Likewise.

	Merge Linux internal_clone() into internal_fork()
	* defs.h (internal_clone): Remove.
	* process.c (internal_clone): Merge into internal_fork().
	(internal_fork) [!LINUX]: Remove dead code.
	* syscall.c (internal_syscall): Replace internal_clone() with
	internal_fork().

	* Makefile.am (INCLUDES): Remove redundant search directories.

2010-02-04  Frederik Schüler  <fs@debian.org>

	Update debian/* files.
	* debian/control: add sparc64 to the architectures list.
	This closes Debian bug #560062
	* Backport commit f0df31e71a58c6e79ba77c1a9d84b2f38d44bec7 to fix FTBFS.
	This closes Debian bug #560516
	* debian/control: Update standards-version to 3.8.3.
	* debian/control: Lower package priority to optional, matching
	the archive override.
	* debian/control: add ${misc:Depends} to Depends: lines where
	appropriate.
	* debian/watch: new file, allows automatic tracking of new
	upstream versions.
	* debian/source/format: new file, adapt to debian source format "quilt"
	* debian/rules: indentation cleanups; use dh_testroot and dh_prep
	in clean target.

2010-01-25  Andreas Schwab  <schwab@redhat.com>

	Fix spurious failure of AC_STAT64 test.
	* acinclude.m4 (AC_STAT64): Include <sys/types.h> first.

2010-01-12  Andreas Schwab  <schwab@redhat.com>

	Don't kill the process when detaching.
	* strace.c (detach): Call clearbpt when TCB_BPTSET is set.

2009-12-25  Dmitry V. Levin  <ldv@altlinux.org>

	Decode fifth argument of mremap syscall.
	* mem.c (sys_mremap): Decode fifth argument.
	* linux/*/syscallent.h: Update the number of mremap syscall arguments.

2009-12-24  Chris Metcalf  <cmetcalf@tilera.com>

	* mem.c (sys_mbind): Display first argument in hex.

	* mem.c (mremap_flags): Add MREMAP_FIXED.

2009-11-16  Mike Frysinger  <vapier@gentoo.org>

	Move i386-specific files out of common linux dir.
	* linux/syscallent.h: Moved to ...
	* linux/i386/syscallent.h: ... here.
	* linux/ia64/syscallent.h: Update i386 syscallent.h include.
	* linux/sparc/gen.pl: Likewise.
	* linux/x86_64/syscallent1.h: Likewise.

2009-11-16  Andreas Schwab  <schwab@redhat.com>

	Remove support for pre-C89.
	* defs.h: Remove references to __STDC__ and P macros.
	* strace.c: Likewise.

2009-11-13  Dmitry V. Levin  <ldv@altlinux.org>

	Decode more SOL_PACKET socket options.
	* net.c (sockpacketoptions): Add more PACKET_* entries.
	(sys_getsockopt): Decode PACKET_STATISTICS.
	(printsockopt): Decode PACKET_RX_RING and PACKET_TX_RING.
	Patch by Gabor Gombas.

2009-11-11  Andreas Schwab  <schwab@redhat.com>

	Ignore errors if a thread is killed.
	* util.c (clearbpt): Ignore ESRCH error.

2009-11-06  Bernhard Reutner-Fischer  <rep.dot.nop@gmail.com>

	Fix handling of Linux systems without struct statfs64.
	* acinclude.m4 (AC_STATFS64): New macro to check for struct statfs64.
	* configure.ac: Call AC_STATFS64.
	* file.c (printstatfs64, sys_statfs64, sys_fstatfs64): Compile only
	  if struct statfs64 is available.

2009-11-06  Dmitry V. Levin  <ldv@altlinux.org>

	Fix getsockopt decoding on architectures where sizeof(long) > sizeof(int)
	* net.c (sys_getsockopt): Optimize output a bit.
	Decode integer argument using printnum_int(), patch by Gabor Gombas.

	Check umove() return code.
	* bjm.c (sys_query_module): Print input parameters when entering
	syscall.  Fix handling of syscall error.  Handle unlikely umove()
	failures.
	* ipc.c (tprint_msgrcv): New function.  Move part of msgrcv parser code
	here, add check umove() return code.
	(sys_msgsnd): Print msqid parameter as int instead of long.
	(sys_msgrcv): Likewise.  Use tprint_msgrcv().
	* process.c (print_affinitylist): Check umove() return code.
	* sock.c (sock_ioctl): Handle unlikely umove() failure in the
	SIOCGIFCONF parser.

	Fix check for linux/netlink.h on Linux 2.6.32-rc5+
	* configure.ac (AC_CHECK_HEADERS): In check for linux/netlink.h, include
	sys/socket.h instead of linux/socket.h beforehand.

2009-11-04  Andreas Schwab  <schwab@redhat.com>

	Decode fallocate on PowerPC.
	* linux/powerpc/syscallent.h: Decode fallocate.

	Factor out printing of 64bit syscall argument.
	* defs.h (ALIGN64): Remove.
	(printllval): Declare.
	* util.c (printllval): Define.
	* file.c (sys_readahead): Use printllval.
	(sys_lseek64): Likewise.
	(sys_truncate64): Likewise.
	(sys_ftruncate64): Likewise.
	(sys_fadvise64): Likewise.
	(sys_fadvise64_64): Likewise.
	(sys_fallocate): Likewise.
	* io.c (sys_pread): Likewise.
	(sys_pwrite): Likewise.
	(sys_pread64): Likewise.
	(sys_pwrite64): Likewise.
	* mem.c (sys_mmap64): Likewise.

2009-11-03  Andreas Schwab  <schwab@redhat.com>

	Correct decoding of readahead and fadvice64(_64) on PowerPC.
	* file.c (sys_readahead): Align 64bit argument.  Handle PowerPC64
	like other 64bit architectures.
	(sys_fadvise64): Likewise.
	(sys_fadvise64_64): Handle PowerPC like ARM.
	* linux/powerpc/syscallent.h (sys_readahead): Account for 64bit
	argument alignment on PowerPC32.

2009-10-27  Andreas Schwab  <schwab@redhat.com>

	Maintain separate print column for each process.
	* defs.h (struct tcp): Add curcol.
	* strace.c: (alloc_tcb): Initialize it.
	(trace): Use curcol from current process and save it before
	continuing.
	(tprintf): Don't modify curcol on output error.

2009-10-21  Roland McGrath  <roland@redhat.com>

	* strace.spec: 4.5.19-1 release.

2009-10-21  Dmitry V. Levin  <ldv@altlinux.org>

	* file.c (printstat64): Cleanup trailing whitespace.

2009-10-16  Andreas Schwab  <schwab@redhat.com>

	Fix decoding of newfstatat syscall on x86-64.
	* file.c (printstat64) [LINUX && X68_64]: If tracing a 64-bit
	process redirect to printstat.
	Fixes RH#529316 "Field values shown for "newfstatat" system
	call are incorrect"

2009-10-12  Dmitry V. Levin  <ldv@altlinux.org>

	* configure.ac (AC_CHECK_HEADERS): Remove asm/reg.h.

2009-10-12  Mike Frysinger  <vapier@gentoo.org>

	sparc/linux: Rewrite to use asm/ptrace.h.
	The current sparc/linux code uses asm/reg.h, but recent Linux kernels
	dropped that header completely.  So switch over to the ptrace headers
	as those should stick around indefinitely as part of the ABI.

	* defs.h [LINUXSPARC] (U_REG_G1, U_REG_O0, U_REG_O1): Define.
	* process.c: Drop asm/regs.h include.
	[SPARC || SPARC64] (change_syscall): Change struct regs to struct pt_regs.
	* signal.c: Drop asm/regs.h include.
	(m_siginfo_t): Unify [SPARC || SPARC64] and [MIPS].
	[SPARC || SPARC64] (sys_sigreturn): Change struct regs to struct pt_regs.
	* syscall.c: Drop asm/regs.h include.
	[SPARC || SPARC64] (internal_syscall, get_scno, get_error, force_result,
	syscall_enter): Change struct regs to struct pt_regs.
	* util.c: Drop asm/regs.h include.
	(_hack_syscall5, _ptrace): Delete.
	[SPARC || SPARC64] (getpc, printcall, arg_setup_state): Change
	struct regs to struct pt_regs.

2009-10-11  Roland McGrath  <roland@redhat.com>

	* make-dist: Clean up.

	* configure.ac: Use AC_CONFIG_AUX_DIR([.]).

2009-10-09  Dmitry V. Levin  <ldv@altlinux.org>

	* make-dist: New script for preparing release tarballs.

	* git-set-file-times: Import from rsync.

	* Makefile.am [MAINTAINER_MODE]: Define and export TAR_OPTIONS.

2009-10-08  Dmitry V. Levin  <ldv@altlinux.org>

	Enhance msgsnd() parser.
	* ipc.c (tprint_msgsnd): New function.  Move msgsnd parser code here,
	add check for umove() return code.
	(sys_msgsnd): Use tprint_msgsnd().

	* NEWS: Update for 4.5.19 release.

	Enhance semop()/semtimedop() sembuf parser.
	* ipc.c (tprint_sembuf): New function. Move sembuf parser code here,
	add abbrev() support.
	(sys_semop, sys_semtimedop): Use tprint_sembuf().

2009-10-08  Jakub Bogusz  <qboosh@pld-linux.org>

	Add pretty printing of sembuf argument to semop() and semtimedop()
	* ipc.c (semop_flags): New xlat structure.
	(sys_semop, sys_semtimedop): Add pretty printing of sembuf argument.

2009-10-08  Mike Frysinger  <vapier@gentoo.org>

	Add support for Linux/no-mmu with vfork.
	* configure.ac (AC_CHECK_FUNCS): Add fork.
	* strace.c (strace_vforked): Define.
	(startup_child): Do not raise SIGSTOP if vforked.
	(trace): Skip first exec when starting up after vforked.
	* syscall.c [BFIN] (get_scno): Drop waitexec checks.

	Avoid malloc(0) in getdents parsers.
	On end of directory, getdents returns 0.  This return value is used to
	then try and do malloc(0), but on some systems this will always return
	NULL.  Since the code won't read the pointer in question if len is 0,
	then don't bother calling malloc(0) and set the pointer to NULL ourself.
	* file.c (sys_getdents, sys_getdents64): Avoid malloc(0) call.

2009-10-07  Mike Frysinger  <vapier@gentoo.org>

	Add sys_nanosleep() prototype for sparc.
	* linux/sparc/syscall.h (sys_nanosleep): New prototype.
	Reported by Frederik Schüler.

	Silence compiler warnings about implicit cast from pointer to integer.
	* util.c (do_ptrace): Cast ptrace() 4th arg to long.
	(ptrace_restart): Drop void* cast on ptrace() 4th arg.

	Ignore .gdb files from FLAT toolchains.
	* .gitignore: Add /*.gdb.

	* configure.ac (AC_CHECK_FUNCS): Sort and expand.

	Blackfin: Update ioctl/syscall lists.
	* linux/bfin/ioctlent.h: Sync list with latest kernel sources.
	* linux/bfin/syscallent.h: Likewise.

	ioctlsort: Check ppc hosts too.
	* linux/ioctlsort.c: Check for __powerpc__.

2009-10-07  Andreas Schwab  <schwab@redhat.com>

	Fix build on ia64.
	* linux/ia64/syscallent.h: Update for addition of accept4 syscall
	in ../syscallent.h.

2009-10-07  Roland McGrath  <roland@redhat.com>

	* strace.spec (%doc): Add ChangeLog-CVS.

	* Makefile.am (srpm): New phony target.

	* Makefile.am (EXTRA_DIST): Add ChangeLog.
	($(srcdir)/ChangeLog): New target, replaces gen-changelog phony target.
	Put it inside [MAINTAINER_MODE].

2009-10-06  Dmitry V. Levin  <ldv@altlinux.org>

	* NEWS: Update for 4.5.19 release.

2009-10-05  Frederik Schüler  <fs@debian.org>

	Prepare debian/* files for release.
	* debian/rules: Do not ship ChangeLog anymore.
	* debian/control: Update to Debian standards version 3.8.1, and remove
	Roland from the Maintainers list.  This closes Debian bug #521458.
	* debian/changelog: Document changes and prepare for release.

2009-10-05  Dmitry V. Levin  <ldv@altlinux.org>

	* defs.h [HPPA]: Lower MAX_ARGS from 32 to 6.

	* ipc.c [LINUX] (sys_shmat): HPPA does not use an IPC multiplexer.
	Based on patch from Carlos O'Donell.

2009-10-05  Carlos O'Donell  <carlos@systemhalted.org>

	* linux/hppa/syscallent.h: Update syscalls.
	Based on work by Kyle McMartin and Helge Deller.

	Fix SA_HANDLER function pointer comparisons for hppa.
	* signal.c (sys_sigaction): Cast SA_HANDLER function pointers to long.
	(sys_rt_sigaction): Likewise.

2009-10-05  Edgar E. Iglesias  <edgar.iglesias@gmail.com>

	CRIS: Correct first argument to upeek()
	This complements commit ea0e6e80260d2b1b7ad40282012b0e47869bcddf.
	* syscall.c [CRISV10 || CRISV32] (syscall_fixup, syscall_enter): Pass
	tcp pointer instead of pid to upeek().
	* util.c [CRISV10 || CRISV32] (printcall): Likewise.

2009-10-05  Dmitry V. Levin  <ldv@altlinux.org>

	* signal.c (do_signalfd): Fix typo in output format.

2009-09-21  Dmitry V. Levin  <ldv@altlinux.org>

	* Makefile.am (gen_changelog_start_date): Fix date.

2009-09-19  Dmitry V. Levin  <ldv@altlinux.org>

	Prepare for 4.5.19 release.
	* NEWS: Update for 4.5.19 release.
	* configure.ac: Version 4.5.19.
	* debian/changelog: 4.5.19-1.
	* strace.spec: 4.5.19-1.

	Update debian/* to 4.5.18-1.
	* debian/changelog: Update to 4.5.18-1.
	* debian/compat: Set compatibility level to 7.
	* debian/control (Build-Depends): Update debhelper requirement.
	(strace, strace64): Add Section and Priority tags.

2009-09-19  Kirill A. Shutemov  <kirill@shutemov.name>

	Fix fadvise64 decoding on ARM.
	* file.c (sys_fadvise64_64) [ARM]: Fix argument ordering.

2009-09-18  Dmitry V. Levin  <ldv@altlinux.org>

	Fix follow fork/vfork on Linux ARM OABI.
	__NR_SYSCALL_BASE eis 0 for EABI and is 0x900000 for OABI.
	* process (change_syscall) [LINUX && ARM]: Mask off the high order bits
	when changing syscall.

	Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name>

2009-09-18  Mike Frysinger  <vapier@gentoo.org>

	Mark shell scripts as executable.

	Ignore ioctlsort helper program.
	* .gitignore: Add ioctlsort.

	linux/errno: Add ERFKILL.
	* linux/errnoent.h: Change ERRNO_132 to ERFKILL according to errno 132
	definition introduced in Linux 2.6.31.

2009-09-01  Paolo Bonzini  <pbonzini@redhat.com>

	Add accept4 socketcall.
	This second patch in the series adds support for accept4 as a socketcall
	sub-call.  Besides the need to renumber all system calls, this poses
	no problem.
	Tested on i686.

	* linux/arm/syscallent.h: Add accept4 socketcall.
	* linux/m68k/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sh/syscallent.h: Likewise.
	* linux/sh64/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/syscallent.h: Likewise.

	* linux/sparc/syscall.h (SYS_sub_accept4): Declare.
	(SYS_socket_nsubcalls): Update.
	* linux/syscall.h: Likewise.

	Replace x86-64 paccept with accept4.
	This patch changes the paccept syscall to accept4 for x86-64, since
	the former was dropped in Linux kernel commit v2.6.27-rc7-14-g2d4c826.
	At the same time, it adds support for pretty printing its arguments.

	* linux/x86_64/syscallent.h: Replace paccept with accept4,
	hook in sys_accept4.
	* net.c (sys_accept): Leave a small stub calling the new...
	(do_accept): ... function, which also adds a flags_arg argument.
	(sys_accept4): New.

2009-08-28  Andreas Schwab  <schwab@redhat.com>

	Zero-extend 32-bit addresses when printing argv array.
	(printargv): Zero-extend 32-bit addresses.
	Fixes RH#519480 "64-bit strace is lazy on execve of 32-bit
	process".

2009-08-12  Andreas Schwab  <schwab@redhat.com>

	Add more futex decoding.
	* process.c (FUTEX_WAIT_REQUEUE_PI, FUTEX_CMP_REQUEUE_PI)
	(FUTEX_PRIVATE_FLAG, FUTEX_CLOCK_REALTIME): Define.
	(futexops): Add entries for them.
	(sys_futex): Decode FUTEX_CMP_REQUEUE_PI and
	FUTEX_WAIT_REQUEUE_PI.

2009-07-08  Dmitry V. Levin  <ldv@altlinux.org>

	Generate ChangeLog from git log.
	* .gitignore: Add ChangeLog
	* ChangeLog: Rename to ChangeLog-CVS.
	* Makefile.am (gen-changelog): New rule.
	(dist-hook): Depend on it.
	(EXTRA_DIST): Add ChangeLog-CVS.
	* README-hacking: Describe changes.
	* gitlog-to-changelog: Import from gnulib.


See ChangeLog-CVS for older changes.
